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