PIbd-22. Safiulova K.N. LabWork_05_base #9

Closed
safiulova.k wants to merge 16 commits from LabWork_05 into LabWork_04
2 changed files with 62 additions and 19 deletions
Showing only changes of commit a02b349485 - Show all commits

View File

@ -0,0 +1,38 @@
2024-04-24 08:40:44,201 INFO Microsoft.Hosting.Lifetime.? [?] - MESSAGE: Now listening on: https://localhost:7282
2024-04-24 08:40:44,324 INFO Microsoft.Hosting.Lifetime.? [?] - MESSAGE: Now listening on: http://localhost:5121
2024-04-24 08:40:44,335 INFO Microsoft.Hosting.Lifetime.OnApplicationStarted [0] - MESSAGE: Application started. Press Ctrl+C to shut down.
2024-04-24 08:40:44,343 INFO Microsoft.Hosting.Lifetime.OnApplicationStarted [0] - MESSAGE: Hosting environment: Development
2024-04-24 08:40:44,345 INFO Microsoft.Hosting.Lifetime.OnApplicationStarted [0] - MESSAGE: Content root path: C:\Users\Admin\Desktop\4 семестр\rpp\AircraftPlant\AircraftPlantRestApi\
2024-04-24 08:51:47,124 INFO AircraftPlantBusinessLogic.BusinessLogics.PlaneLogic.ReadList [47] - MESSAGE: ReadList. PlaneName:(null).Id:(null)
2024-04-24 08:51:53,278 INFO AircraftPlantBusinessLogic.BusinessLogics.PlaneLogic.ReadList [56] - MESSAGE: ReadList. Count:2
2024-04-24 08:52:00,134 INFO AircraftPlantBusinessLogic.BusinessLogics.PlaneLogic.ReadList [47] - MESSAGE: ReadList. PlaneName:(null).Id:(null)
2024-04-24 08:52:00,219 INFO AircraftPlantBusinessLogic.BusinessLogics.PlaneLogic.ReadList [56] - MESSAGE: ReadList. Count:2
2024-04-24 08:52:18,354 INFO AircraftPlantBusinessLogic.BusinessLogics.ClientLogic.ReadElement [45] - MESSAGE: ReadElement. ClientEmail:client3@email.com.Id:(null)
2024-04-24 08:52:18,764 INFO AircraftPlantBusinessLogic.BusinessLogics.ClientLogic.ReadElement [54] - MESSAGE: ReadElement find. Id:3
2024-04-24 08:52:19,045 INFO AircraftPlantBusinessLogic.BusinessLogics.OrderLogic.ReadList [48] - MESSAGE: ReadList. Order.Id:(null)
2024-04-24 08:52:19,234 INFO AircraftPlantBusinessLogic.BusinessLogics.OrderLogic.ReadList [57] - MESSAGE: ReadList. Count:3
2024-04-24 08:52:20,379 INFO AircraftPlantBusinessLogic.BusinessLogics.PlaneLogic.ReadList [47] - MESSAGE: ReadList. PlaneName:(null).Id:(null)
2024-04-24 08:52:20,419 INFO AircraftPlantBusinessLogic.BusinessLogics.PlaneLogic.ReadList [56] - MESSAGE: ReadList. Count:2
2024-04-24 08:52:23,606 INFO AircraftPlantBusinessLogic.BusinessLogics.PlaneLogic.ReadElement [72] - MESSAGE: ReadElement. PlaneName:(null).Id:1
2024-04-24 08:52:23,703 INFO AircraftPlantBusinessLogic.BusinessLogics.PlaneLogic.ReadElement [81] - MESSAGE: ReadElement find. Id:1
2024-04-24 08:52:24,634 INFO AircraftPlantBusinessLogic.BusinessLogics.PlaneLogic.ReadElement [72] - MESSAGE: ReadElement. PlaneName:(null).Id:1
2024-04-24 08:52:24,645 INFO AircraftPlantBusinessLogic.BusinessLogics.PlaneLogic.ReadElement [81] - MESSAGE: ReadElement find. Id:1
2024-04-24 08:52:24,742 INFO AircraftPlantBusinessLogic.BusinessLogics.OrderLogic.CheckModel [137] - MESSAGE: Order. OrderID:0.Sum:203500. PlaneId: 1
2024-04-24 08:52:25,281 INFO AircraftPlantBusinessLogic.BusinessLogics.OrderLogic.ReadList [48] - MESSAGE: ReadList. Order.Id:(null)
2024-04-24 08:52:25,296 INFO AircraftPlantBusinessLogic.BusinessLogics.OrderLogic.ReadList [57] - MESSAGE: ReadList. Count:4
2024-04-24 09:01:48,304 INFO AircraftPlantBusinessLogic.BusinessLogics.PlaneLogic.ReadList [47] - MESSAGE: ReadList. PlaneName:(null).Id:(null)
2024-04-24 09:01:48,420 INFO AircraftPlantBusinessLogic.BusinessLogics.PlaneLogic.ReadList [56] - MESSAGE: ReadList. Count:2
2024-04-24 09:02:19,753 INFO AircraftPlantBusinessLogic.BusinessLogics.ClientLogic.ReadElement [45] - MESSAGE: ReadElement. ClientEmail:client2@email.com.Id:(null)
2024-04-24 09:02:19,781 INFO AircraftPlantBusinessLogic.BusinessLogics.ClientLogic.ReadElement [54] - MESSAGE: ReadElement find. Id:2
2024-04-24 09:02:19,812 INFO AircraftPlantBusinessLogic.BusinessLogics.OrderLogic.ReadList [48] - MESSAGE: ReadList. Order.Id:(null)
2024-04-24 09:02:19,831 INFO AircraftPlantBusinessLogic.BusinessLogics.OrderLogic.ReadList [57] - MESSAGE: ReadList. Count:2
2024-04-24 09:02:21,217 INFO AircraftPlantBusinessLogic.BusinessLogics.PlaneLogic.ReadList [47] - MESSAGE: ReadList. PlaneName:(null).Id:(null)
2024-04-24 09:02:21,244 INFO AircraftPlantBusinessLogic.BusinessLogics.PlaneLogic.ReadList [56] - MESSAGE: ReadList. Count:2
2024-04-24 09:02:23,961 INFO AircraftPlantBusinessLogic.BusinessLogics.PlaneLogic.ReadElement [72] - MESSAGE: ReadElement. PlaneName:(null).Id:1
2024-04-24 09:02:23,979 INFO AircraftPlantBusinessLogic.BusinessLogics.PlaneLogic.ReadElement [81] - MESSAGE: ReadElement find. Id:1
2024-04-24 09:02:24,922 INFO AircraftPlantBusinessLogic.BusinessLogics.PlaneLogic.ReadElement [72] - MESSAGE: ReadElement. PlaneName:(null).Id:1
2024-04-24 09:02:24,931 INFO AircraftPlantBusinessLogic.BusinessLogics.PlaneLogic.ReadElement [81] - MESSAGE: ReadElement find. Id:1
2024-04-24 09:02:24,942 INFO AircraftPlantBusinessLogic.BusinessLogics.OrderLogic.CheckModel [137] - MESSAGE: Order. OrderID:0.Sum:407000. PlaneId: 1
2024-04-24 09:02:24,984 INFO AircraftPlantBusinessLogic.BusinessLogics.OrderLogic.ReadList [48] - MESSAGE: ReadList. Order.Id:(null)
2024-04-24 09:02:24,994 INFO AircraftPlantBusinessLogic.BusinessLogics.OrderLogic.ReadList [57] - MESSAGE: ReadList. Count:3

View File

@ -14,13 +14,14 @@ namespace AircraftPlantDatabaseImplement.Implements
using var context = new AircraftPlantDatabase();
return context.Orders
.Include(x => x.Plane)
.Include(x => x.Client)
.Select(x => x.GetViewModel)
.ToList();
}
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
if (!model.Id.HasValue && (!model.DateFrom.HasValue || !model.DateTo.HasValue))
if (!model.Id.HasValue && !model.ClientId.HasValue && (!model.DateFrom.HasValue || !model.DateTo.HasValue))
{
return new();
}
@ -28,13 +29,26 @@ namespace AircraftPlantDatabaseImplement.Implements
if (model.DateFrom.HasValue)
{
return context.Orders
.Include(x => x.Client)
.Include(x => x.Plane)
.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
.Select(x => x.GetViewModel)
.ToList();
}
if (model.ClientId.HasValue)
{
return context.Orders
.Include(x => x.Plane)
.Include(x => x.Client)
.Where(x => x.ClientId == model.ClientId)
.Select(x => x.GetViewModel)
.ToList();
}
return context.Orders
.Include(x => x.Plane)
.Include(x => x.Client)
.Where(x => x.Id == model.Id)
.Select(x => x.GetViewModel)
.ToList();
@ -49,24 +63,22 @@ namespace AircraftPlantDatabaseImplement.Implements
using var context = new AircraftPlantDatabase();
return context.Orders
.Include(x => x.Plane)
.FirstOrDefault(x => x.Id == model.Id)
?.GetViewModel;
.Include(x => x.Client)
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?
.GetViewModel;
}
public OrderViewModel? Insert(OrderBindingModel model)
{
var newOrder = Order.Create(model);
using var context = new AircraftPlantDatabase();
var newOrder = Order.Create(context, model);
if (newOrder == null)
{
return null;
}
using var context = new AircraftPlantDatabase();
context.Orders.Add(newOrder);
context.SaveChanges();
return context.Orders
.Include(x => x.Plane)
.FirstOrDefault(x => x.Id == newOrder.Id)
?.GetViewModel;
return newOrder.GetViewModel;
}
public OrderViewModel? Update(OrderBindingModel model)
@ -79,25 +91,18 @@ namespace AircraftPlantDatabaseImplement.Implements
}
order.Update(model);
context.SaveChanges();
return context.Orders
.Include(x => x.Plane)
.FirstOrDefault(x => x.Id == model.Id)
?.GetViewModel;
return order.GetViewModel;
}
public OrderViewModel? Delete(OrderBindingModel model)
{
using var context = new AircraftPlantDatabase();
var element = context.Orders.FirstOrDefault(rec => rec.Id == model.Id);
var element = context.Orders.FirstOrDefault(x => x.Id == model.Id);
if (element != null)
{
var deletedElement = context.Orders
.Include(x => x.Plane)
.FirstOrDefault(x => x.Id == model.Id)
?.GetViewModel;
context.Orders.Remove(element);
context.SaveChanges();
return deletedElement;
return element.GetViewModel;
}
return null;
}