fix client app p.2
This commit is contained in:
parent
c41f0e635f
commit
e4536d16c0
@ -82,7 +82,7 @@ namespace CarShowroomBusinessLogic.BusinessLogic
|
|||||||
return;
|
return;
|
||||||
if (string.IsNullOrEmpty(model.Name))
|
if (string.IsNullOrEmpty(model.Name))
|
||||||
throw new InvalidOperationException();
|
throw new InvalidOperationException();
|
||||||
if (model.Cost < 0)
|
if (model.Price < 0)
|
||||||
throw new InvalidOperationException();
|
throw new InvalidOperationException();
|
||||||
var element = _serviceStorage.GetElement(new ServiceSearch
|
var element = _serviceStorage.GetElement(new ServiceSearch
|
||||||
{
|
{
|
||||||
|
@ -10,6 +10,6 @@ namespace CarShowroomContracts.AbstractModels
|
|||||||
public interface IService : IId
|
public interface IService : IId
|
||||||
{
|
{
|
||||||
string Name { get; }
|
string Name { get; }
|
||||||
int Cost { get; }
|
int Price { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,12 +11,12 @@ namespace CarShowroomDataModels.Dtos
|
|||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public int Cost { get; set; }
|
public int Price { get; set; }
|
||||||
public ServiceDto(IService model)
|
public ServiceDto(IService model)
|
||||||
{
|
{
|
||||||
Id = model.Id;
|
Id = model.Id;
|
||||||
Name = model.Name;
|
Name = model.Name;
|
||||||
Cost = model.Cost;
|
Price = model.Price;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,6 @@ namespace CarShowroomDataModels.Views
|
|||||||
{
|
{
|
||||||
[DisplayName("Номер машины")]
|
[DisplayName("Номер машины")]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[DisplayName("Название машины")]
|
|
||||||
public string Name { get; set; } = string.Empty;
|
|
||||||
[DisplayName("Цвет")]
|
[DisplayName("Цвет")]
|
||||||
public string Color { get; set; }
|
public string Color { get; set; }
|
||||||
[DisplayName("Дата производства")]
|
[DisplayName("Дата производства")]
|
||||||
@ -22,7 +20,7 @@ namespace CarShowroomDataModels.Views
|
|||||||
[DisplayName("Модель")]
|
[DisplayName("Модель")]
|
||||||
public string ModelName { get; set; } = string.Empty;
|
public string ModelName { get; set; } = string.Empty;
|
||||||
[DisplayName("Цена")]
|
[DisplayName("Цена")]
|
||||||
public int ModelPrice { get; set; }
|
public int Price { get; set; }
|
||||||
[DisplayName("Марка")]
|
[DisplayName("Марка")]
|
||||||
public string MakeName { get; set; } = string.Empty;
|
public string MakeName { get; set; } = string.Empty;
|
||||||
[DisplayName("Продана")]
|
[DisplayName("Продана")]
|
||||||
|
@ -11,12 +11,12 @@ namespace CarShowroomDataModels.Views
|
|||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public int Cost { get; set; }
|
public int Price { get; set; }
|
||||||
public ServiceView(IService model)
|
public ServiceView(IService model)
|
||||||
{
|
{
|
||||||
Id = model.Id;
|
Id = model.Id;
|
||||||
Name = model.Name;
|
Name = model.Name;
|
||||||
Cost = model.Cost;
|
Price = model.Price;
|
||||||
}
|
}
|
||||||
public ServiceView() { }
|
public ServiceView() { }
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ namespace CarShowroomDatabaseStorage
|
|||||||
modelBuilder.Entity<Employee>().Property(e => e.Password).HasDefaultValue("empty_string");
|
modelBuilder.Entity<Employee>().Property(e => e.Password).HasDefaultValue("empty_string");
|
||||||
modelBuilder.Entity<Car>().Property(c => c.Color).HasDefaultValue("empty_string");
|
modelBuilder.Entity<Car>().Property(c => c.Color).HasDefaultValue("empty_string");
|
||||||
modelBuilder.Entity<Car>().Property(c => c.IsSaled).HasDefaultValue(false);
|
modelBuilder.Entity<Car>().Property(c => c.IsSaled).HasDefaultValue(false);
|
||||||
modelBuilder.Entity<Service>().Property(c => c.Cost).HasDefaultValue(-1);
|
modelBuilder.Entity<Service>().Property(c => c.Price).HasDefaultValue(-1);
|
||||||
modelBuilder.Entity<Model>().Property(c => c.Price).HasDefaultValue(-1);
|
modelBuilder.Entity<Model>().Property(c => c.Price).HasDefaultValue(-1);
|
||||||
modelBuilder.Entity<Sale>().Property(c => c.Cost).HasDefaultValue(-1);
|
modelBuilder.Entity<Sale>().Property(c => c.Cost).HasDefaultValue(-1);
|
||||||
//on delete actions
|
//on delete actions
|
||||||
|
@ -61,10 +61,9 @@ namespace CarShowroomDatabaseStorage.Entities
|
|||||||
public CarView GetView()
|
public CarView GetView()
|
||||||
{
|
{
|
||||||
CarView car = new CarView(this);
|
CarView car = new CarView(this);
|
||||||
car.ModelPrice = Model?.Price ?? 0;
|
car.Price = Model?.Price ?? 0;
|
||||||
car.ModelName = Model?.Name ?? string.Empty;
|
car.ModelName = Model?.Name ?? string.Empty;
|
||||||
car.MakeName = Model?.Make?.Name ?? string.Empty;
|
car.MakeName = Model?.Make?.Name ?? string.Empty;
|
||||||
car.Name = car.Color + " " + car.MakeName + " " + car.ModelName;
|
|
||||||
return car;
|
return car;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ namespace CarShowroomDatabaseStorage.Entities
|
|||||||
public string Name { get; private set; } = string.Empty;
|
public string Name { get; private set; } = string.Empty;
|
||||||
[Required]
|
[Required]
|
||||||
[Column("service_cost")]
|
[Column("service_cost")]
|
||||||
public int Cost { get; private set; }
|
public int Price { get; private set; }
|
||||||
public virtual List<SaleService> SaleServices { get; set; } = new();
|
public virtual List<SaleService> SaleServices { get; set; } = new();
|
||||||
|
|
||||||
private Service() { }
|
private Service() { }
|
||||||
@ -33,7 +33,7 @@ namespace CarShowroomDatabaseStorage.Entities
|
|||||||
{
|
{
|
||||||
Id = service.Id;
|
Id = service.Id;
|
||||||
Name = service.Name;
|
Name = service.Name;
|
||||||
Cost = service.Cost;
|
Price = service.Price;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Service? Create(IService service)
|
public static Service? Create(IService service)
|
||||||
@ -48,7 +48,7 @@ namespace CarShowroomDatabaseStorage.Entities
|
|||||||
if (service == null)
|
if (service == null)
|
||||||
return;
|
return;
|
||||||
Name = service.Name;
|
Name = service.Name;
|
||||||
Cost = service.Cost;
|
Price = service.Price;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServiceView GetView()
|
public ServiceView GetView()
|
||||||
|
@ -3,6 +3,7 @@ using CarShowroomDatabaseStorage.Entities;
|
|||||||
using CarShowroomDataModels.Dtos;
|
using CarShowroomDataModels.Dtos;
|
||||||
using CarShowroomDataModels.SearchModel;
|
using CarShowroomDataModels.SearchModel;
|
||||||
using CarShowroomDataModels.Views;
|
using CarShowroomDataModels.Views;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -17,7 +18,9 @@ namespace CarShowroomDatabaseStorage.Storages
|
|||||||
{
|
{
|
||||||
using var context = new CarShowroomDatabase();
|
using var context = new CarShowroomDatabase();
|
||||||
return context.Cars
|
return context.Cars
|
||||||
.Select(x => x.GetView())
|
.Include(c => c.Model)
|
||||||
|
.ThenInclude(m => m.Make)
|
||||||
|
.Select(x => x.GetView())
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,6 +32,8 @@ namespace CarShowroomDatabaseStorage.Storages
|
|||||||
}
|
}
|
||||||
using var context = new CarShowroomDatabase();
|
using var context = new CarShowroomDatabase();
|
||||||
return context.Cars
|
return context.Cars
|
||||||
|
.Include(c => c.Model)
|
||||||
|
.ThenInclude(m => m.Make)
|
||||||
.Where(x => !model.Id.HasValue || x.Id == model.Id)
|
.Where(x => !model.Id.HasValue || x.Id == model.Id)
|
||||||
.Select(x => x.GetView())
|
.Select(x => x.GetView())
|
||||||
.ToList();
|
.ToList();
|
||||||
|
@ -75,8 +75,8 @@ namespace CarShowroomManagerApp.Controllers
|
|||||||
return Redirect("~/Home/Enter");
|
return Redirect("~/Home/Enter");
|
||||||
}
|
}
|
||||||
ViewBag.Cars = ApiClient.GetRequest<List<CarView>>("api/car/getcarlist");
|
ViewBag.Cars = ApiClient.GetRequest<List<CarView>>("api/car/getcarlist");
|
||||||
ViewBag.Clients = ApiClient.GetRequest<List<CarView>>("api/client/getclientlist");
|
ViewBag.Clients = ApiClient.GetRequest<List<ClientView>>("api/client/getclientlist");
|
||||||
ViewBag.Services = ApiClient.GetRequest<List<CarView>>("api/service/getservicelist");
|
ViewBag.Services = ApiClient.GetRequest<List<ServiceView>>("api/service/getservicelist");
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,7 +132,7 @@ namespace CarShowroomManagerApp.Controllers
|
|||||||
{
|
{
|
||||||
return Redirect("~/Home/Enter");
|
return Redirect("~/Home/Enter");
|
||||||
}
|
}
|
||||||
ViewBag.Shops = ApiClient.GetRequest<List<ClientView>>("api/client/getclientlist");
|
ViewBag.Clients = ApiClient.GetRequest<List<ClientView>>("api/client/getclientlist");
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ namespace CarShowroomManagerApp.Controllers
|
|||||||
Name = name,
|
Name = name,
|
||||||
PhoneNumber = phonenumber
|
PhoneNumber = phonenumber
|
||||||
});
|
});
|
||||||
Response.Redirect("Index");
|
Response.Redirect("Clients");
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActionResult SaleDelete()
|
public IActionResult SaleDelete()
|
||||||
@ -163,7 +163,7 @@ namespace CarShowroomManagerApp.Controllers
|
|||||||
{
|
{
|
||||||
return Redirect("~/Home/Enter");
|
return Redirect("~/Home/Enter");
|
||||||
}
|
}
|
||||||
ViewBag.Shops = ApiClient.GetRequest<List<SaleView>>("api/sale/getsalelist");
|
ViewBag.Sales = ApiClient.GetRequest<List<SaleView>>("api/sale/getsalelist");
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,13 @@
|
|||||||
<h2 class="display-4">Редактирование данных клиента</h2>
|
<h2 class="display-4">Редактирование данных клиента</h2>
|
||||||
</div>
|
</div>
|
||||||
<form method="post">
|
<form method="post">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">Клиент:</div>
|
||||||
|
<div class="col-8">
|
||||||
|
<select name="client" id="client" class="form-control"
|
||||||
|
asp-items="@(new SelectList(@ViewBag.Clients, "Id", "Name"))"></select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Номер телефона:</div>
|
<div class="col-4">Номер телефона:</div>
|
||||||
<div class="col-8"><input type="text" name="phonenumber" /></div>
|
<div class="col-8"><input type="text" name="phonenumber" /></div>
|
||||||
@ -17,7 +24,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-8"></div>
|
<div class="col-8"></div>
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
<input type="submit" value="C"
|
<input type="submit" value="Cохранить данные"
|
||||||
class="btn btn-primary" />
|
class="btn btn-primary" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -5,12 +5,12 @@
|
|||||||
<h2 class="display-4">Продажа</h2>
|
<h2 class="display-4">Продажа</h2>
|
||||||
</div>
|
</div>
|
||||||
<form method="post">
|
<form method="post">
|
||||||
<div class="row">
|
@* <div class="row">
|
||||||
<div class="col-4">Сумма:</div>
|
<div class="col-4">Сумма:</div>
|
||||||
<div class="col-8">
|
<div class="col-8">
|
||||||
<input type="number" name="sum" id="sum" readonly/>
|
<input type="number" name="sum" id="sum" readonly/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div> *@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Клиент:</div>
|
<div class="col-4">Клиент:</div>
|
||||||
<div class="col-8">
|
<div class="col-8">
|
||||||
@ -24,7 +24,7 @@
|
|||||||
<select name="cars" id="cars" class="form-control" multiple size="5">
|
<select name="cars" id="cars" class="form-control" multiple size="5">
|
||||||
@foreach (var car in ViewBag.Cars)
|
@foreach (var car in ViewBag.Cars)
|
||||||
{
|
{
|
||||||
<option value="@car.Id">@car.Name</option>
|
<option value="@car.Id">@car.Color @car.MakeName @car.ModelName, @car.Price рублей</option>
|
||||||
}
|
}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@ -35,7 +35,7 @@
|
|||||||
<select name="services" id="services" class="form-control" multiple size="5">
|
<select name="services" id="services" class="form-control" multiple size="5">
|
||||||
@foreach (var service in ViewBag.Services)
|
@foreach (var service in ViewBag.Services)
|
||||||
{
|
{
|
||||||
<option value="@service.Id">@service.Name</option>
|
<option value="@service.Id">@service.Name, @service.Price рублей</option>
|
||||||
}
|
}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
5
CarShowroom/CarShowroomManagerApp/libman.json
Normal file
5
CarShowroom/CarShowroomManagerApp/libman.json
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"version": "1.0",
|
||||||
|
"defaultProvider": "cdnjs",
|
||||||
|
"libraries": []
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user