list and db fixes
This commit is contained in:
parent
5cc65fd547
commit
f6be017910
@ -38,7 +38,7 @@ namespace SushiBarDatabaseImplement.Implements
|
||||
.FirstOrDefault(x => x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
if (model.ImplementerId.HasValue && model.OrderStatus.HasValue)
|
||||
else if (model.ImplementerId.HasValue && model.OrderStatus.HasValue)
|
||||
{
|
||||
return context.Orders
|
||||
.Include(x => x.Sushi)
|
||||
@ -46,6 +46,14 @@ namespace SushiBarDatabaseImplement.Implements
|
||||
.FirstOrDefault(x => x.ImplementerId == model.ImplementerId && x.Status == model.OrderStatus)
|
||||
?.GetViewModel;
|
||||
}
|
||||
else if (model.ImplementerId.HasValue)
|
||||
{
|
||||
return context.Orders
|
||||
.Include(x => x.Sushi)
|
||||
.Include(x => x.Client).Include(x => x.Implementer)
|
||||
.FirstOrDefault(x => x.ImplementerId == model.ImplementerId)
|
||||
?.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -91,6 +99,7 @@ namespace SushiBarDatabaseImplement.Implements
|
||||
return context.Orders
|
||||
.Include(x => x.Sushi)
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Implementer)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
@ -108,6 +117,7 @@ namespace SushiBarDatabaseImplement.Implements
|
||||
return context.Orders
|
||||
.Include(x => x.Sushi)
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Implementer)
|
||||
.FirstOrDefault(x => x.Id == newOrder.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
@ -118,6 +128,7 @@ namespace SushiBarDatabaseImplement.Implements
|
||||
var order = context.Orders
|
||||
.Include(x => x.Sushi)
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Implementer)
|
||||
.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (order == null)
|
||||
{
|
||||
|
@ -26,7 +26,7 @@ namespace SushiBarListImplement.Implements
|
||||
{
|
||||
var result = new List<OrderViewModel>();
|
||||
|
||||
if (model.DateFrom.HasValue)
|
||||
if (model.DateFrom.HasValue && model.DateTo.HasValue)
|
||||
{
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
@ -46,6 +46,16 @@ namespace SushiBarListImplement.Implements
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (model.OrderStatus.HasValue)
|
||||
{
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
if (order.Status == model.OrderStatus)
|
||||
{
|
||||
result.Add(GetViewModel(order));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (model.Id.HasValue)
|
||||
{
|
||||
foreach (var order in _source.Orders)
|
||||
@ -92,6 +102,14 @@ namespace SushiBarListImplement.Implements
|
||||
break;
|
||||
}
|
||||
}
|
||||
foreach (var implementer in _source.Implementers)
|
||||
{
|
||||
if (implementer.Id == order.ImplementerId)
|
||||
{
|
||||
viewModel.ImplementerFIO = implementer.ImplementerFIO;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return viewModel;
|
||||
}
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
|
@ -1,11 +1,6 @@
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.ViewModels;
|
||||
using SushiBarDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SushiBarListImplement.Models
|
||||
{
|
||||
|
@ -2,7 +2,6 @@
|
||||
using SushiBarContracts.ViewModels;
|
||||
using SushiBarDataModels.Enums;
|
||||
using SushiBarDataModels.Models;
|
||||
using System.Reflection;
|
||||
|
||||
namespace SushiBarListImplement.Models
|
||||
{
|
||||
@ -11,6 +10,7 @@ namespace SushiBarListImplement.Models
|
||||
public int Id { get; private set; }
|
||||
public int SushiId { get; private set; }
|
||||
public int ClientId { get; private set; }
|
||||
public int? ImplementerId { get; private set; }
|
||||
public int Count { get; private set; }
|
||||
public double Sum { get; private set; }
|
||||
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
||||
@ -26,6 +26,7 @@ namespace SushiBarListImplement.Models
|
||||
{
|
||||
SushiId = model.SushiId,
|
||||
ClientId = model.ClientId,
|
||||
ImplementerId = model.ImplementerId,
|
||||
Count = model.Count,
|
||||
Sum = model.Sum,
|
||||
Status = model.Status,
|
||||
@ -41,12 +42,14 @@ namespace SushiBarListImplement.Models
|
||||
return;
|
||||
}
|
||||
Status = model.Status;
|
||||
ImplementerId = model.ImplementerId;
|
||||
DateImplement = model.DateImplement;
|
||||
}
|
||||
public OrderViewModel GetViewModel => new()
|
||||
{
|
||||
SushiId = SushiId,
|
||||
ClientId = ClientId,
|
||||
ImplementerId = ImplementerId,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
DateCreate = DateCreate,
|
||||
|
@ -3,6 +3,7 @@ using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.BusinessLogicsContracts;
|
||||
using SushiBarContracts.SearchModels;
|
||||
using SushiBarContracts.ViewModels;
|
||||
using SushiBarDataModels.Enums;
|
||||
|
||||
namespace SushiBarRestApi.Controllers
|
||||
{
|
||||
@ -48,7 +49,7 @@ namespace SushiBarRestApi.Controllers
|
||||
{
|
||||
return _order.ReadList(new OrderSearchModel
|
||||
{
|
||||
//Status = OrderStatus.Принят
|
||||
OrderStatus = OrderStatus.Принят
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -65,7 +66,7 @@ namespace SushiBarRestApi.Controllers
|
||||
{
|
||||
return _order.ReadElement(new OrderSearchModel
|
||||
{
|
||||
//ImplementerId = implementerId
|
||||
ImplementerId = implementerId
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
Loading…
Reference in New Issue
Block a user