fix filtration

This commit is contained in:
Zakharov_Rostislav 2024-05-13 15:48:30 +04:00
parent f4dd73833d
commit d617260cb3
3 changed files with 20 additions and 25 deletions

View File

@ -26,7 +26,7 @@ namespace CarShowroomDatabaseStorage.Storages
public List<CarView> GetFilteredList(CarSearch model) public List<CarView> GetFilteredList(CarSearch model)
{ {
if (!model.Id.HasValue) if (!model.Id.HasValue && !model.IsSaled.HasValue)
{ {
return new(); return new();
} }

View File

@ -57,8 +57,8 @@ namespace CarShowroomDatabaseStorage.Storages
var newSale = Sale.Create(model); var newSale = Sale.Create(model);
if (newSale == null) if (newSale == null)
throw new InvalidOperationException("SaleId is incorrect"); throw new InvalidOperationException("SaleId is incorrect");
int saleId = context.Sales.Add(newSale).CurrentValues.GetValue<int>("Id");
context.SaveChanges(); context.SaveChanges();
int saleId = context.Sales.Add(newSale).CurrentValues.GetValue<int>("Id");
SaleView result = UpdateCarsAndServices(context, model, saleId); SaleView result = UpdateCarsAndServices(context, model, saleId);
transaction.Commit(); transaction.Commit();
return result; return result;

View File

@ -80,27 +80,22 @@ namespace CarShowroomManagerApp.Controllers
return View(); return View();
} }
//[HttpPost] [HttpPost]
//public void SaleCreate(int manufacture, int count) public void SaleCreate(int client, List<int> cars, List<int> services)
//{ {
// if (APIClient.Client == null) if (ApiClient.Client == null)
// { {
// throw new Exception("Вы как суда попали? Суда вход только авторизованным"); Redirect("~/Home/Enter");
// } }
// if (count <= 0) ApiClient.PostRequest("api/sale/createsale", new
// { SaleDto
// throw new Exception("Количество и сумма должны быть больше 0"); {
// } ClientId = client,
// APIClient.PostRequest("api/main/createorder", new CarIds = cars,
// OrderBindingModel ServiceIds = services
// { });
// ClientId = APIClient.Client.Id, Response.Redirect("Index");
// ManufactureId = manufacture, }
// Count = count,
// Sum = Calc(count, manufacture)
// });
// Response.Redirect("Index");
//}
public IActionResult ClientCreate() public IActionResult ClientCreate()
{ {
@ -137,7 +132,7 @@ namespace CarShowroomManagerApp.Controllers
} }
[HttpPost] [HttpPost]
public void ClientUpdate(string phonenumber, string name) public void ClientUpdate(int client, string phonenumber, string name)
{ {
if (ApiClient.Client == null) if (ApiClient.Client == null)
{ {
@ -150,7 +145,7 @@ namespace CarShowroomManagerApp.Controllers
} }
ApiClient.PostRequest("api/client/updateclient", new ClientDto ApiClient.PostRequest("api/client/updateclient", new ClientDto
{ {
Id = ApiClient.Client.Id, Id = client,
Name = name, Name = name,
PhoneNumber = phonenumber PhoneNumber = phonenumber
}); });