From a02b34948523242c79f0e1909fcd10f77ff1859a Mon Sep 17 00:00:00 2001 From: kamilia Date: Sun, 5 May 2024 23:08:13 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BF=D0=BE=D1=84=D0=B8=D0=BA=D1=81=D0=B8?= =?UTF-8?q?=D0=BB=D0=B0=20=D0=BA=D0=BE=D0=BD=D1=84=D0=BB=D0=B8=D0=BA=D1=82?= =?UTF-8?q?=20=D1=82=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20=D0=B2=D1=81=D1=91=20?= =?UTF-8?q?=D0=BC=D0=B8=D1=80=D0=BD=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AircraftPlant/AircraftPlant.log.2024-04-24 | 38 ++++++++++++++++ .../Implements/OrderStorage.cs | 43 +++++++++++-------- 2 files changed, 62 insertions(+), 19 deletions(-) create mode 100644 AircraftPlant/AircraftPlant.log.2024-04-24 diff --git a/AircraftPlant/AircraftPlant.log.2024-04-24 b/AircraftPlant/AircraftPlant.log.2024-04-24 new file mode 100644 index 0000000..d2fa31c --- /dev/null +++ b/AircraftPlant/AircraftPlant.log.2024-04-24 @@ -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 + \ No newline at end of file diff --git a/AircraftPlant/AircraftPlantDatabaseImplement/Implements/OrderStorage.cs b/AircraftPlant/AircraftPlantDatabaseImplement/Implements/OrderStorage.cs index f9b5346..745c49e 100644 --- a/AircraftPlant/AircraftPlantDatabaseImplement/Implements/OrderStorage.cs +++ b/AircraftPlant/AircraftPlantDatabaseImplement/Implements/OrderStorage.cs @@ -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 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; }