crud full complete
This commit is contained in:
parent
a15bdf9d95
commit
19fb713cb8
@ -153,67 +153,65 @@ namespace CanteenBusinessLogic.BusinessLogics
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool AddOrder(LunchOrderBindingModel model)
|
public bool UpdateOrders(LunchBindingModel lunch, OrderBindingModel order)
|
||||||
{
|
{
|
||||||
CheckModel(model, false);
|
var _lunch = _lunchStorage.GetElement(new LunchSearchModel { Id = lunch.Id});
|
||||||
_logger.LogInformation("AddOrder. LunchId: {LunchId}. OrderId: {OrderId}. CountOrder: {CountOrder}", model.OrderId, model.LunchId, model.OrderCount);
|
_lunch.LunchOrders[order.Id] = order as IOrderModel;
|
||||||
if (!_lunchStorage.AddOrder(model))
|
if (_lunchStorage.Update(new()
|
||||||
{
|
{
|
||||||
_logger.LogWarning("AddOrder operation failed");
|
Id = _lunch.Id,
|
||||||
|
LunchName = _lunch.LunchName,
|
||||||
|
Sum = _lunch.Sum,
|
||||||
|
VisitorId = _lunch.VisitorId,
|
||||||
|
LunchOrders = _lunch.LunchOrders
|
||||||
|
|
||||||
|
}) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
private void CheckModel(LunchOrderBindingModel model, bool withParams = true)
|
|
||||||
|
public bool UpdateProducts(LunchBindingModel lunch, ProductBindingModel product, int count)
|
||||||
{
|
{
|
||||||
if (model == null)
|
var _lunch = _lunchStorage.GetElement(new LunchSearchModel { Id = lunch.Id });
|
||||||
|
if (count == -1)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(model));
|
if (_lunch.LunchProducts.ContainsKey(product.Id))
|
||||||
|
{
|
||||||
|
_lunch.LunchProducts.Remove(product.Id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (count > 0)
|
||||||
|
{
|
||||||
|
_lunch.LunchProducts[product.Id] = (product, count);
|
||||||
|
}
|
||||||
|
double allSum = 0;
|
||||||
|
foreach (var lunchProducts in _lunch.LunchProducts)
|
||||||
|
{
|
||||||
|
IProductModel _product = lunchProducts.Value.Item1;
|
||||||
|
int _count = lunchProducts.Value.Item2;
|
||||||
|
allSum += _product.Price * _count;
|
||||||
|
}
|
||||||
|
if (_lunchStorage.Update(new()
|
||||||
|
{
|
||||||
|
Id = _lunch.Id,
|
||||||
|
LunchName = _lunch.LunchName,
|
||||||
|
VisitorId = _lunch.VisitorId,
|
||||||
|
LunchProducts = _lunch.LunchProducts,
|
||||||
|
DateCreate = _lunch.DateCreate,
|
||||||
|
Status = _lunch.Status,
|
||||||
|
DateImplement = _lunch.DateImplement,
|
||||||
|
Sum = allSum
|
||||||
|
}) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!withParams)
|
return true;
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (model.OrderId <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("id заказа должен быть больше 0", nameof(model.OrderId));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (model.LunchId <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("id обеда должен быть больше 0", nameof(model.LunchId));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (model.VisitorId <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("id посетителя должен быть больше 0", nameof(model.VisitorId));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (model.OrderCount <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("количество одного заказа должно быть больше 0", nameof(model.OrderCount));
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("LunchOrder. OrderId: {OrderId}. LunchId: {LunchId}. VisitorId: {VisitorId}. OrderCount: {OrderCount}", model.OrderId, model.LunchId, model.VisitorId, model.OrderCount);
|
|
||||||
|
|
||||||
var element = _lunchStorage.GetLunchOrderElement(new LunchOrderSearchModel { Id = model.Id, OrderId = model.OrderId, LunchId = model.LunchId });
|
|
||||||
if (element != null && element.Id != model.Id)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("Такая связь уже есть");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool AddProductToLunch(LunchSearchModel model, IProductModel product, int count)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool AddOrderToLunch(LunchSearchModel model, IOrderModel order, int count)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,16 +25,6 @@ namespace CanteenBusinessLogic.BusinessLogics
|
|||||||
_orderStorage = orderStorage;
|
_orderStorage = orderStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool AddCooksToOrder(OrderSearchModel model, ICookModel cook)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool AddTablewareToOrder(OrderTablewareBindingModel model, ITablewareModel tableware, int count)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Create(OrderBindingModel model)
|
public bool Create(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
@ -110,6 +100,56 @@ namespace CanteenBusinessLogic.BusinessLogics
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool UpdateCooks(OrderBindingModel order, CookBindingModel cook)
|
||||||
|
{
|
||||||
|
var _order = _orderStorage.GetElement(new OrderSearchModel { Id = order.Id });
|
||||||
|
_order.OrderCooks[cook.Id] = cook as ICookModel;
|
||||||
|
if (_orderStorage.Update(new()
|
||||||
|
{
|
||||||
|
Id = _order.Id,
|
||||||
|
Description = _order.Description,
|
||||||
|
VisitorId = _order.VisitorId,
|
||||||
|
OrderCooks = _order.OrderCooks
|
||||||
|
|
||||||
|
}) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool UpdateTablewares(OrderBindingModel order, TablewareBindingModel tableware, int count)
|
||||||
|
{
|
||||||
|
var _order = _orderStorage.GetElement(new OrderSearchModel { Id = order.Id });
|
||||||
|
if (count == -1)
|
||||||
|
{
|
||||||
|
if (_order.OrderTablewares.ContainsKey(tableware.Id))
|
||||||
|
{
|
||||||
|
_order.OrderTablewares.Remove(tableware.Id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (count > 0)
|
||||||
|
{
|
||||||
|
_order.OrderTablewares[tableware.Id] = (tableware, count);
|
||||||
|
}
|
||||||
|
if (_orderStorage.Update(new()
|
||||||
|
{
|
||||||
|
Id = _order.Id,
|
||||||
|
Description = _order.Description,
|
||||||
|
VisitorId = _order.VisitorId,
|
||||||
|
OrderTablewares = _order.OrderTablewares
|
||||||
|
|
||||||
|
}) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private void CheckModel(OrderBindingModel model, bool withParams = true)
|
private void CheckModel(OrderBindingModel model, bool withParams = true)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
@ -132,12 +172,7 @@ namespace CanteenBusinessLogic.BusinessLogics
|
|||||||
throw new ArgumentNullException("id посетителя должен быть больше 0", nameof(model.VisitorId));
|
throw new ArgumentNullException("id посетителя должен быть больше 0", nameof(model.VisitorId));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model.Sum <= 0)
|
_logger.LogInformation("Order. Description: {Description}. VisitorId: {VisitorId}. Id: {Id}", model.Description, model.VisitorId, model.Id);
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Сумма заказа должна быть больше 0", nameof(model.Sum));
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("Order. Description: {Description}. Sum: {Sum}. VisitorId: {VisitorId}. Id: {Id}", model.Description, model.Sum, model.VisitorId, model.Id);
|
|
||||||
|
|
||||||
var element = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
|
var element = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
|
||||||
if (element != null && element.Id != model.Id)
|
if (element != null && element.Id != model.Id)
|
||||||
@ -145,80 +180,5 @@ namespace CanteenBusinessLogic.BusinessLogics
|
|||||||
throw new InvalidOperationException("Заказ с таким id уже есть");
|
throw new InvalidOperationException("Заказ с таким id уже есть");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void CheckModel(OrderCookBindingModel model, bool withParams = true)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!withParams)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (model.OrderId <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("id заказа должен быть больше 0", nameof(model.OrderId));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (model.CookId <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("id повара должен быть больше 0", nameof(model.CookId));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (model.VisitorId <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("id посетителя должен быть больше 0", nameof(model.VisitorId));
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("OrderCook. OrderId: {OrderId}. CookId: {CookId}. VisitorId: {VisitorId}", model.OrderId, model.CookId, model.VisitorId);
|
|
||||||
|
|
||||||
var element = _orderStorage.GetOrderCookElement(new OrderCookSearchModel { Id = model.Id, OrderId = model.OrderId, CookId = model.CookId });
|
|
||||||
if (element != null && element.Id != model.Id)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("Такая связь уже есть");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void CheckModel(OrderTablewareBindingModel model, bool withParams = true)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!withParams)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (model.OrderId <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("id заказа должен быть больше 0", nameof(model.OrderId));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (model.TablewareId <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("id прибора должен быть больше 0", nameof(model.TablewareId));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (model.VisitorId <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("id посетителя должен быть больше 0", nameof(model.VisitorId));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (model.CountTablewares <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("количество одного прибора должено быть больше 0", nameof(model.CountTablewares));
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("OrderTableware. OrderId: {OrderId}. TablewareId: {TablewareId}. VisitorId: {VisitorId}. CountTablewares: {CountTablewares}", model.OrderId, model.TablewareId, model.VisitorId, model.CountTablewares);
|
|
||||||
|
|
||||||
var element = _orderStorage.GetElement(new OrderSearchModel { Id = model.OrderId});
|
|
||||||
//if (element != null && element.Id == model.OrderId && element.TablewareId == model.TablewareId)
|
|
||||||
//{
|
|
||||||
// throw new InvalidOperationException("Такая связь уже есть");
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,6 @@ namespace CanteenContracts.BindingModels
|
|||||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||||
public DateTime? DateImplement { get; set; }
|
public DateTime? DateImplement { get; set; }
|
||||||
public Dictionary<int, (IProductModel, int)> LunchProducts { get; set; } = new Dictionary<int, (IProductModel, int)>();
|
public Dictionary<int, (IProductModel, int)> LunchProducts { get; set; } = new Dictionary<int, (IProductModel, int)>();
|
||||||
public Dictionary<int, (IOrderModel, int)> LunchOrders { get; set; } = new Dictionary<int, (IOrderModel, int)>();
|
public Dictionary<int, IOrderModel> LunchOrders { get; set; } = new Dictionary<int, IOrderModel>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,6 @@ namespace CanteenContracts.BindingModels
|
|||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public int VisitorId { get; set; }
|
public int VisitorId { get; set; }
|
||||||
public string Description { get; set; } = string.Empty;
|
public string Description { get; set; } = string.Empty;
|
||||||
public double? Sum { get; set; }
|
|
||||||
public int? TablewareId { get; set; }
|
|
||||||
public int? CountTablewares { get; set; }
|
public int? CountTablewares { get; set; }
|
||||||
public Dictionary<int, ICookModel> OrderCooks { get; set; } = new ();
|
public Dictionary<int, ICookModel> OrderCooks { get; set; } = new ();
|
||||||
public Dictionary<int, (ITablewareModel, int)> OrderTablewares { get; set; } = new ();
|
public Dictionary<int, (ITablewareModel, int)> OrderTablewares { get; set; } = new ();
|
||||||
|
@ -18,7 +18,7 @@ namespace CanteenContracts.BusinessLogicsContracts
|
|||||||
bool Update(LunchBindingModel model);
|
bool Update(LunchBindingModel model);
|
||||||
bool Delete(LunchBindingModel model);
|
bool Delete(LunchBindingModel model);
|
||||||
bool Finish(LunchBindingModel model);
|
bool Finish(LunchBindingModel model);
|
||||||
bool AddProductToLunch(LunchSearchModel model, IProductModel product, int count);
|
bool UpdateOrders(LunchBindingModel lunch, OrderBindingModel order);
|
||||||
bool AddOrderToLunch(LunchSearchModel model, IOrderModel order, int count);
|
bool UpdateProducts(LunchBindingModel lunch, ProductBindingModel product, int count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ namespace CanteenContracts.BusinessLogicsContracts
|
|||||||
bool Create(OrderBindingModel model);
|
bool Create(OrderBindingModel model);
|
||||||
bool Delete(OrderBindingModel model);
|
bool Delete(OrderBindingModel model);
|
||||||
bool Update(OrderBindingModel model);
|
bool Update(OrderBindingModel model);
|
||||||
bool AddTablewareToOrder(OrderTablewareBindingModel model, ITablewareModel tableware, int count);
|
bool UpdateTablewares(OrderBindingModel order, TablewareBindingModel tableware, int count);
|
||||||
bool AddCooksToOrder(OrderSearchModel model, ICookModel cook);
|
bool UpdateCooks(OrderBindingModel order, CookBindingModel cooks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,5 @@ namespace CanteenContracts.StoragesContracts
|
|||||||
LunchViewModel? Insert(LunchBindingModel model);
|
LunchViewModel? Insert(LunchBindingModel model);
|
||||||
LunchViewModel? Update(LunchBindingModel model);
|
LunchViewModel? Update(LunchBindingModel model);
|
||||||
LunchViewModel? Delete(LunchBindingModel model);
|
LunchViewModel? Delete(LunchBindingModel model);
|
||||||
bool AddOrder(LunchOrderBindingModel model);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ namespace CanteenContracts.View
|
|||||||
public DateTime DateCreate { get; set; }
|
public DateTime DateCreate { get; set; }
|
||||||
[DisplayName("Дата реализации")]
|
[DisplayName("Дата реализации")]
|
||||||
public DateTime? DateImplement { get; set; }
|
public DateTime? DateImplement { get; set; }
|
||||||
public Dictionary<int, (IProductModel, int)> LunchProducts { get; set; } = new();
|
public Dictionary<int, (IProductModel, int)> LunchProducts { get; set; }
|
||||||
|
public Dictionary<int, IOrderModel> LunchOrders { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ using System.ComponentModel;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace CanteenContracts.View
|
namespace CanteenContracts.View
|
||||||
{
|
{
|
||||||
@ -15,12 +16,15 @@ namespace CanteenContracts.View
|
|||||||
public int VisitorId { get; set; }
|
public int VisitorId { get; set; }
|
||||||
[DisplayName("Описание")]
|
[DisplayName("Описание")]
|
||||||
public string Description { get; set; } = string.Empty;
|
public string Description { get; set; } = string.Empty;
|
||||||
[DisplayName("Сумма")]
|
public Dictionary<int, ICookModel> OrderCooks { get; set; }
|
||||||
public double? Sum { get; set; }
|
public Dictionary<int, (ITablewareModel, int)> OrderTablewares { get; set; }
|
||||||
public Dictionary<int, ICookModel> OrderCooks { get; set; } = new Dictionary<int, ICookModel>();
|
|
||||||
public Dictionary<int, (ITablewareModel, int)> OrderTablewares { get; set; } = new Dictionary<int, (ITablewareModel, int)>();
|
|
||||||
[DisplayName("ID заказа")]
|
[DisplayName("ID заказа")]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
public OrderViewModel() { }
|
||||||
|
[JsonConstructor]
|
||||||
|
public OrderViewModel(Dictionary<int, CookViewModel> OrderCooks)
|
||||||
|
{
|
||||||
|
this.OrderCooks = OrderCooks.ToDictionary(x => x.Key, x => x.Value as ICookModel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ namespace CanteenContracts.View
|
|||||||
[DisplayName("ID менеджера")]
|
[DisplayName("ID менеджера")]
|
||||||
public int ManagerId { get; set; }
|
public int ManagerId { get; set; }
|
||||||
|
|
||||||
public Dictionary<int, ICookModel> ProductCooks { get; set; } = new();
|
public Dictionary<int, ICookModel> ProductCooks { get; set; }
|
||||||
|
|
||||||
public ProductViewModel() { }
|
public ProductViewModel() { }
|
||||||
[JsonConstructor]
|
[JsonConstructor]
|
||||||
|
@ -11,7 +11,6 @@ namespace CanteenDataModels.Models
|
|||||||
{
|
{
|
||||||
int VisitorId { get; }
|
int VisitorId { get; }
|
||||||
string Description { get; }
|
string Description { get; }
|
||||||
double? Sum { get; }
|
|
||||||
Dictionary<int, ICookModel> OrderCooks { get; }
|
Dictionary<int, ICookModel> OrderCooks { get; }
|
||||||
Dictionary<int, (ITablewareModel, int)> OrderTablewares { get; }
|
Dictionary<int, (ITablewareModel, int)> OrderTablewares { get; }
|
||||||
}
|
}
|
||||||
|
@ -21,83 +21,98 @@ namespace CanteenDatabaseImplement
|
|||||||
.HasOne(dp => dp.Dish)
|
.HasOne(dp => dp.Dish)
|
||||||
.WithMany(d => d.Products)
|
.WithMany(d => d.Products)
|
||||||
.HasForeignKey(dp => dp.DishId)
|
.HasForeignKey(dp => dp.DishId)
|
||||||
.OnDelete(DeleteBehavior.NoAction);
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
|
||||||
modelBuilder.Entity<DishProduct>()
|
modelBuilder.Entity<DishProduct>()
|
||||||
.HasOne(dp => dp.Product)
|
.HasOne(dp => dp.Product)
|
||||||
.WithMany(p => p.Dishes)
|
.WithMany(p => p.Dishes)
|
||||||
.HasForeignKey(dp => dp.ProductId)
|
.HasForeignKey(dp => dp.ProductId)
|
||||||
.OnDelete(DeleteBehavior.NoAction);
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
//=====================================
|
//=====================================
|
||||||
|
|
||||||
modelBuilder.Entity<LunchOrder>()
|
modelBuilder.Entity<LunchOrder>()
|
||||||
.HasOne(dp => dp.Lunch)
|
.HasOne(dp => dp.Lunch)
|
||||||
.WithMany(d => d.Orders)
|
.WithMany(d => d.Orders)
|
||||||
.HasForeignKey(dp => dp.LunchId)
|
.HasForeignKey(dp => dp.LunchId)
|
||||||
.OnDelete(DeleteBehavior.NoAction);
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
|
||||||
modelBuilder.Entity<LunchOrder>()
|
modelBuilder.Entity<LunchOrder>()
|
||||||
.HasOne(dp => dp.Order)
|
.HasOne(dp => dp.Order)
|
||||||
.WithMany(p => p.Lunches)
|
.WithMany(p => p.Lunches)
|
||||||
.HasForeignKey(dp => dp.OrderId)
|
.HasForeignKey(dp => dp.OrderId)
|
||||||
.OnDelete(DeleteBehavior.NoAction);
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
//=====================================
|
//=====================================
|
||||||
|
|
||||||
modelBuilder.Entity<LunchProduct>()
|
modelBuilder.Entity<LunchProduct>()
|
||||||
.HasOne(dp => dp.Lunch)
|
.HasOne(dp => dp.Lunch)
|
||||||
.WithMany(d => d.Products)
|
.WithMany(d => d.Products)
|
||||||
.HasForeignKey(dp => dp.LunchId)
|
.HasForeignKey(dp => dp.LunchId)
|
||||||
.OnDelete(DeleteBehavior.NoAction);
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
|
||||||
modelBuilder.Entity<LunchProduct>()
|
modelBuilder.Entity<LunchProduct>()
|
||||||
.HasOne(dp => dp.Product)
|
.HasOne(dp => dp.Product)
|
||||||
.WithMany(p => p.Lunches)
|
.WithMany(p => p.Lunches)
|
||||||
.HasForeignKey(dp => dp.ProductId)
|
.HasForeignKey(dp => dp.ProductId)
|
||||||
.OnDelete(DeleteBehavior.NoAction);
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
//=====================================
|
//=====================================
|
||||||
|
|
||||||
modelBuilder.Entity<OrderCook>()
|
modelBuilder.Entity<OrderCook>()
|
||||||
.HasOne(dp => dp.Order)
|
.HasOne(dp => dp.Order)
|
||||||
.WithMany(d => d.Cooks)
|
.WithMany(d => d.Cooks)
|
||||||
.HasForeignKey(dp => dp.OrderId)
|
.HasForeignKey(dp => dp.OrderId)
|
||||||
.OnDelete(DeleteBehavior.NoAction);
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
|
||||||
modelBuilder.Entity<OrderCook>()
|
modelBuilder.Entity<OrderCook>()
|
||||||
.HasOne(dp => dp.Cook)
|
.HasOne(dp => dp.Cook)
|
||||||
.WithMany(p => p.Orders)
|
.WithMany(p => p.Orders)
|
||||||
.HasForeignKey(dp => dp.CookId)
|
.HasForeignKey(dp => dp.CookId)
|
||||||
.OnDelete(DeleteBehavior.NoAction);
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
//=====================================
|
//=====================================
|
||||||
|
|
||||||
modelBuilder.Entity<OrderTableware>()
|
modelBuilder.Entity<OrderTableware>()
|
||||||
.HasOne(dp => dp.Order)
|
.HasOne(dp => dp.Order)
|
||||||
.WithMany(d => d.Tablewares)
|
.WithMany(d => d.Tablewares)
|
||||||
.HasForeignKey(dp => dp.OrderId)
|
.HasForeignKey(dp => dp.OrderId)
|
||||||
.OnDelete(DeleteBehavior.NoAction);
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
|
||||||
modelBuilder.Entity<OrderTableware>()
|
modelBuilder.Entity<OrderTableware>()
|
||||||
.HasOne(dp => dp.Tableware)
|
.HasOne(dp => dp.Tableware)
|
||||||
.WithMany(p => p.Orders)
|
.WithMany(p => p.Orders)
|
||||||
.HasForeignKey(dp => dp.TablewareId)
|
.HasForeignKey(dp => dp.TablewareId)
|
||||||
.OnDelete(DeleteBehavior.NoAction);
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
//=====================================
|
//=====================================
|
||||||
|
|
||||||
modelBuilder.Entity<ProductCook>()
|
modelBuilder.Entity<ProductCook>()
|
||||||
.HasOne(dp => dp.Product)
|
.HasOne(dp => dp.Product)
|
||||||
.WithMany(d => d.Cooks)
|
.WithMany(d => d.Cooks)
|
||||||
.HasForeignKey(dp => dp.ProductId)
|
.HasForeignKey(dp => dp.ProductId)
|
||||||
.OnDelete(DeleteBehavior.NoAction);
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
|
||||||
modelBuilder.Entity<ProductCook>()
|
modelBuilder.Entity<ProductCook>()
|
||||||
.HasOne(dp => dp.Cook)
|
.HasOne(dp => dp.Cook)
|
||||||
.WithMany(p => p.Products)
|
.WithMany(p => p.Products)
|
||||||
.HasForeignKey(dp => dp.CookId)
|
.HasForeignKey(dp => dp.CookId)
|
||||||
.OnDelete(DeleteBehavior.NoAction);
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
//=====================================
|
//=====================================
|
||||||
modelBuilder.Entity<Order>()
|
modelBuilder.Entity<Order>()
|
||||||
.HasOne(b => b.Visitor)
|
.HasOne(b => b.Visitor)
|
||||||
.WithMany(a => a.Orders)
|
.WithMany(a => a.Orders)
|
||||||
.OnDelete(DeleteBehavior.NoAction);
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
//=====================================
|
||||||
|
modelBuilder.Entity<Lunch>()
|
||||||
|
.HasOne(b => b.Visitor)
|
||||||
|
.WithMany(a => a.Lunches)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
//=====================================
|
||||||
|
modelBuilder.Entity<Order>()
|
||||||
|
.HasOne(b => b.Visitor)
|
||||||
|
.WithMany(a => a.Orders)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
//=====================================
|
||||||
|
modelBuilder.Entity<Order>()
|
||||||
|
.HasOne(b => b.Visitor)
|
||||||
|
.WithMany(a => a.Orders)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
//=====================================
|
//=====================================
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -42,13 +42,18 @@ namespace CanteenDatabaseImplement.Implements
|
|||||||
return context.Dishes
|
return context.Dishes
|
||||||
.Include(x => x.Products)
|
.Include(x => x.Products)
|
||||||
.ThenInclude(x => x.Product)
|
.ThenInclude(x => x.Product)
|
||||||
.Where(x => x.DishName == model.DishName || (model.ManagerId.HasValue && model.ManagerId == x.ManagerId)).Select(x => x.GetViewModel).ToList();
|
.Where(x => x.DishName == model.DishName || (model.ManagerId.HasValue && model.ManagerId == x.ManagerId))
|
||||||
|
.Select(x => x.GetViewModel).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DishViewModel> GetFullList()
|
public List<DishViewModel> GetFullList()
|
||||||
{
|
{
|
||||||
using var context = new CanteenDatabase();
|
using var context = new CanteenDatabase();
|
||||||
return context.Dishes.Include(x => x.Products).ThenInclude(x => x.Product).Select(x => x.GetViewModel).ToList();
|
return context.Dishes
|
||||||
|
.Include(x => x.Products)
|
||||||
|
.ThenInclude(x => x.Product)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DishViewModel? Insert(DishBindingModel model)
|
public DishViewModel? Insert(DishBindingModel model)
|
||||||
@ -99,7 +104,7 @@ namespace CanteenDatabaseImplement.Implements
|
|||||||
dish.Update(model);
|
dish.Update(model);
|
||||||
|
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
dish.UpdateDishProduct(context, model);
|
if (model.DishProducts.Any()) dish.UpdateDishProduct(context, model);
|
||||||
context.Database.CommitTransaction();
|
context.Database.CommitTransaction();
|
||||||
|
|
||||||
return dish.GetViewModel;
|
return dish.GetViewModel;
|
||||||
|
@ -28,6 +28,8 @@ namespace CanteenDatabaseImplement.Implements
|
|||||||
return context.Lunches
|
return context.Lunches
|
||||||
.Include(x => x.Products)
|
.Include(x => x.Products)
|
||||||
.ThenInclude(x => x.Product)
|
.ThenInclude(x => x.Product)
|
||||||
|
.Include(x => x.Orders)
|
||||||
|
.ThenInclude(x => x.Order)
|
||||||
.FirstOrDefault(x => (x.DateCreate >= model.DateFrom && x.DateImplement <= model.DateTo) || (x.Id == model.Id))?.GetViewModel;
|
.FirstOrDefault(x => (x.DateCreate >= model.DateFrom && x.DateImplement <= model.DateTo) || (x.Id == model.Id))?.GetViewModel;
|
||||||
}
|
}
|
||||||
public LunchOrderViewModel? GetLunchOrderElement(LunchOrderSearchModel model)
|
public LunchOrderViewModel? GetLunchOrderElement(LunchOrderSearchModel model)
|
||||||
@ -44,7 +46,7 @@ namespace CanteenDatabaseImplement.Implements
|
|||||||
}
|
}
|
||||||
public List<LunchViewModel> GetFilteredList(LunchSearchModel model)
|
public List<LunchViewModel> GetFilteredList(LunchSearchModel model)
|
||||||
{
|
{
|
||||||
if (!model.DateFrom.HasValue || !model.DateTo.HasValue)
|
if (!model.VisitorId.HasValue)
|
||||||
{
|
{
|
||||||
return new();
|
return new();
|
||||||
}
|
}
|
||||||
@ -54,6 +56,8 @@ namespace CanteenDatabaseImplement.Implements
|
|||||||
return context.Lunches
|
return context.Lunches
|
||||||
.Include(x => x.Products)
|
.Include(x => x.Products)
|
||||||
.ThenInclude(x => x.Product)
|
.ThenInclude(x => x.Product)
|
||||||
|
.Include(x => x.Orders)
|
||||||
|
.ThenInclude(x => x.Order)
|
||||||
.Where(x =>
|
.Where(x =>
|
||||||
(x.DateCreate >= model.DateFrom && x.DateImplement <= model.DateTo) ||
|
(x.DateCreate >= model.DateFrom && x.DateImplement <= model.DateTo) ||
|
||||||
(model.Id.HasValue && x.Id == model.Id) ||
|
(model.Id.HasValue && x.Id == model.Id) ||
|
||||||
@ -66,6 +70,8 @@ namespace CanteenDatabaseImplement.Implements
|
|||||||
return context.Lunches
|
return context.Lunches
|
||||||
.Include(x => x.Products)
|
.Include(x => x.Products)
|
||||||
.ThenInclude(x => x.Product)
|
.ThenInclude(x => x.Product)
|
||||||
|
.Include(x => x.Orders)
|
||||||
|
.ThenInclude(x => x.Order)
|
||||||
.Select(x => x.GetViewModel).ToList();
|
.Select(x => x.GetViewModel).ToList();
|
||||||
}
|
}
|
||||||
public LunchViewModel? Insert(LunchBindingModel model)
|
public LunchViewModel? Insert(LunchBindingModel model)
|
||||||
@ -115,10 +121,8 @@ namespace CanteenDatabaseImplement.Implements
|
|||||||
lunch.Update(model);
|
lunch.Update(model);
|
||||||
|
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
if (model.LunchProducts != null)
|
if (model.LunchProducts.Any()) lunch.UpdateProducts(context, model);
|
||||||
lunch.UpdateProducts(context, model);
|
if (model.LunchOrders.Any()) lunch.UpdateOrders(context, model);
|
||||||
if (model.LunchOrders != null)
|
|
||||||
lunch.UpdateOrders(context, model);
|
|
||||||
context.Database.CommitTransaction();
|
context.Database.CommitTransaction();
|
||||||
|
|
||||||
return lunch.GetViewModel;
|
return lunch.GetViewModel;
|
||||||
@ -145,30 +149,5 @@ namespace CanteenDatabaseImplement.Implements
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
public bool AddOrder(LunchOrderBindingModel lunchOrder)
|
|
||||||
{
|
|
||||||
using var context = new CanteenDatabase();
|
|
||||||
using var transaction = context.Database.BeginTransaction();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var _lunchOrder = context.LunchOrder.FirstOrDefault(rec => rec.LunchId == lunchOrder.LunchId && rec.OrderId == lunchOrder.OrderId);
|
|
||||||
if (_lunchOrder != null)
|
|
||||||
{
|
|
||||||
_lunchOrder.CountOrders = lunchOrder.OrderCount;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
context.LunchOrder.Add(new LunchOrder { LunchId = lunchOrder.LunchId, OrderId = lunchOrder.OrderId, CountOrders = lunchOrder.OrderCount });
|
|
||||||
}
|
|
||||||
context.SaveChanges();
|
|
||||||
transaction.Commit();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
transaction.Rollback();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,8 +40,11 @@ namespace CanteenDatabaseImplement.Implements
|
|||||||
|
|
||||||
return context.Orders
|
return context.Orders
|
||||||
.Include(x => x.Cooks)
|
.Include(x => x.Cooks)
|
||||||
.ThenInclude(x => x.Cook)
|
.ThenInclude(x => x.Cook)
|
||||||
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)?.GetViewModel;
|
.Include(x => x.Tablewares)
|
||||||
|
.ThenInclude(x => x.Tableware)
|
||||||
|
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)?
|
||||||
|
.GetViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||||
@ -56,6 +59,8 @@ namespace CanteenDatabaseImplement.Implements
|
|||||||
return context.Orders
|
return context.Orders
|
||||||
.Include(x => x.Cooks)
|
.Include(x => x.Cooks)
|
||||||
.ThenInclude(x => x.Cook)
|
.ThenInclude(x => x.Cook)
|
||||||
|
.Include(x => x.Tablewares)
|
||||||
|
.ThenInclude(x => x.Tableware)
|
||||||
.Where(x => (model.Id.HasValue && x.Id == model.Id) || (model.VisitorId.HasValue && model.VisitorId == x.VisitorId)).Select(x => x.GetViewModel).ToList();
|
.Where(x => (model.Id.HasValue && x.Id == model.Id) || (model.VisitorId.HasValue && model.VisitorId == x.VisitorId)).Select(x => x.GetViewModel).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,16 +93,18 @@ namespace CanteenDatabaseImplement.Implements
|
|||||||
{
|
{
|
||||||
using var context = new CanteenDatabase();
|
using var context = new CanteenDatabase();
|
||||||
|
|
||||||
var client = context.Orders.FirstOrDefault(x => x.Id == model.Id);
|
var order = context.Orders.FirstOrDefault(x => x.Id == model.Id);
|
||||||
if (client == null)
|
if (order == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
client.Update(model);
|
order.Update(model);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
|
if (model.OrderTablewares.Any()) order.UpdateOrderTablewares(context, model);
|
||||||
|
if (model.OrderCooks.Any()) order.UpdateOrderCook(context, model);
|
||||||
|
|
||||||
return client.GetViewModel;
|
return order.GetViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderViewModel? Delete(OrderBindingModel model)
|
public OrderViewModel? Delete(OrderBindingModel model)
|
||||||
|
@ -113,7 +113,7 @@ namespace CanteenDatabaseImplement.Implements
|
|||||||
|
|
||||||
product.Update(model);
|
product.Update(model);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
if (model.ProductCooks != null)
|
if (model.ProductCooks.Any())
|
||||||
product.UpdateProductCooks(context, model);
|
product.UpdateProductCooks(context, model);
|
||||||
context.Database.CommitTransaction();
|
context.Database.CommitTransaction();
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|||||||
namespace CanteenDatabaseImplement.Migrations
|
namespace CanteenDatabaseImplement.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(CanteenDatabase))]
|
[DbContext(typeof(CanteenDatabase))]
|
||||||
[Migration("20230518211530_Init")]
|
[Migration("20230519185610_Init")]
|
||||||
partial class Init
|
partial class Init
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -144,9 +144,6 @@ namespace CanteenDatabaseImplement.Migrations
|
|||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
b.Property<int>("CountOrders")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("LunchId")
|
b.Property<int>("LunchId")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
@ -229,9 +226,6 @@ namespace CanteenDatabaseImplement.Migrations
|
|||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("nvarchar(max)");
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
b.Property<double?>("Sum")
|
|
||||||
.HasColumnType("float");
|
|
||||||
|
|
||||||
b.Property<int>("VisitorId")
|
b.Property<int>("VisitorId")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
@ -417,13 +411,13 @@ namespace CanteenDatabaseImplement.Migrations
|
|||||||
b.HasOne("CanteenDatabaseImplement.Models.Dish", "Dish")
|
b.HasOne("CanteenDatabaseImplement.Models.Dish", "Dish")
|
||||||
.WithMany("Products")
|
.WithMany("Products")
|
||||||
.HasForeignKey("DishId")
|
.HasForeignKey("DishId")
|
||||||
.OnDelete(DeleteBehavior.NoAction)
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("CanteenDatabaseImplement.Models.Product", "Product")
|
b.HasOne("CanteenDatabaseImplement.Models.Product", "Product")
|
||||||
.WithMany("Dishes")
|
.WithMany("Dishes")
|
||||||
.HasForeignKey("ProductId")
|
.HasForeignKey("ProductId")
|
||||||
.OnDelete(DeleteBehavior.NoAction)
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.Navigation("Dish");
|
b.Navigation("Dish");
|
||||||
@ -447,13 +441,13 @@ namespace CanteenDatabaseImplement.Migrations
|
|||||||
b.HasOne("CanteenDatabaseImplement.Models.Lunch", "Lunch")
|
b.HasOne("CanteenDatabaseImplement.Models.Lunch", "Lunch")
|
||||||
.WithMany("Orders")
|
.WithMany("Orders")
|
||||||
.HasForeignKey("LunchId")
|
.HasForeignKey("LunchId")
|
||||||
.OnDelete(DeleteBehavior.NoAction)
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("CanteenDatabaseImplement.Models.Order", "Order")
|
b.HasOne("CanteenDatabaseImplement.Models.Order", "Order")
|
||||||
.WithMany("Lunches")
|
.WithMany("Lunches")
|
||||||
.HasForeignKey("OrderId")
|
.HasForeignKey("OrderId")
|
||||||
.OnDelete(DeleteBehavior.NoAction)
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.Navigation("Lunch");
|
b.Navigation("Lunch");
|
||||||
@ -466,13 +460,13 @@ namespace CanteenDatabaseImplement.Migrations
|
|||||||
b.HasOne("CanteenDatabaseImplement.Models.Lunch", "Lunch")
|
b.HasOne("CanteenDatabaseImplement.Models.Lunch", "Lunch")
|
||||||
.WithMany("Products")
|
.WithMany("Products")
|
||||||
.HasForeignKey("LunchId")
|
.HasForeignKey("LunchId")
|
||||||
.OnDelete(DeleteBehavior.NoAction)
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("CanteenDatabaseImplement.Models.Product", "Product")
|
b.HasOne("CanteenDatabaseImplement.Models.Product", "Product")
|
||||||
.WithMany("Lunches")
|
.WithMany("Lunches")
|
||||||
.HasForeignKey("ProductId")
|
.HasForeignKey("ProductId")
|
||||||
.OnDelete(DeleteBehavior.NoAction)
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.Navigation("Lunch");
|
b.Navigation("Lunch");
|
||||||
@ -485,7 +479,7 @@ namespace CanteenDatabaseImplement.Migrations
|
|||||||
b.HasOne("CanteenDatabaseImplement.Models.Visitor", "Visitor")
|
b.HasOne("CanteenDatabaseImplement.Models.Visitor", "Visitor")
|
||||||
.WithMany("Orders")
|
.WithMany("Orders")
|
||||||
.HasForeignKey("VisitorId")
|
.HasForeignKey("VisitorId")
|
||||||
.OnDelete(DeleteBehavior.NoAction)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.Navigation("Visitor");
|
b.Navigation("Visitor");
|
||||||
@ -496,13 +490,13 @@ namespace CanteenDatabaseImplement.Migrations
|
|||||||
b.HasOne("CanteenDatabaseImplement.Models.Cook", "Cook")
|
b.HasOne("CanteenDatabaseImplement.Models.Cook", "Cook")
|
||||||
.WithMany("Orders")
|
.WithMany("Orders")
|
||||||
.HasForeignKey("CookId")
|
.HasForeignKey("CookId")
|
||||||
.OnDelete(DeleteBehavior.NoAction)
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("CanteenDatabaseImplement.Models.Order", "Order")
|
b.HasOne("CanteenDatabaseImplement.Models.Order", "Order")
|
||||||
.WithMany("Cooks")
|
.WithMany("Cooks")
|
||||||
.HasForeignKey("OrderId")
|
.HasForeignKey("OrderId")
|
||||||
.OnDelete(DeleteBehavior.NoAction)
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.Navigation("Cook");
|
b.Navigation("Cook");
|
||||||
@ -515,13 +509,13 @@ namespace CanteenDatabaseImplement.Migrations
|
|||||||
b.HasOne("CanteenDatabaseImplement.Models.Order", "Order")
|
b.HasOne("CanteenDatabaseImplement.Models.Order", "Order")
|
||||||
.WithMany("Tablewares")
|
.WithMany("Tablewares")
|
||||||
.HasForeignKey("OrderId")
|
.HasForeignKey("OrderId")
|
||||||
.OnDelete(DeleteBehavior.NoAction)
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("CanteenDatabaseImplement.Models.Tableware", "Tableware")
|
b.HasOne("CanteenDatabaseImplement.Models.Tableware", "Tableware")
|
||||||
.WithMany("Orders")
|
.WithMany("Orders")
|
||||||
.HasForeignKey("TablewareId")
|
.HasForeignKey("TablewareId")
|
||||||
.OnDelete(DeleteBehavior.NoAction)
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.Navigation("Order");
|
b.Navigation("Order");
|
||||||
@ -545,13 +539,13 @@ namespace CanteenDatabaseImplement.Migrations
|
|||||||
b.HasOne("CanteenDatabaseImplement.Models.Cook", "Cook")
|
b.HasOne("CanteenDatabaseImplement.Models.Cook", "Cook")
|
||||||
.WithMany("Products")
|
.WithMany("Products")
|
||||||
.HasForeignKey("CookId")
|
.HasForeignKey("CookId")
|
||||||
.OnDelete(DeleteBehavior.NoAction)
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("CanteenDatabaseImplement.Models.Product", "Product")
|
b.HasOne("CanteenDatabaseImplement.Models.Product", "Product")
|
||||||
.WithMany("Cooks")
|
.WithMany("Cooks")
|
||||||
.HasForeignKey("ProductId")
|
.HasForeignKey("ProductId")
|
||||||
.OnDelete(DeleteBehavior.NoAction)
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.Navigation("Cook");
|
b.Navigation("Cook");
|
@ -137,8 +137,7 @@ namespace CanteenDatabaseImplement.Migrations
|
|||||||
Id = table.Column<int>(type: "int", nullable: false)
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
VisitorId = table.Column<int>(type: "int", nullable: false),
|
VisitorId = table.Column<int>(type: "int", nullable: false),
|
||||||
Description = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
Description = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||||
Sum = table.Column<double>(type: "float", nullable: true)
|
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
@ -147,7 +146,8 @@ namespace CanteenDatabaseImplement.Migrations
|
|||||||
name: "FK_Orders_Visitors_VisitorId",
|
name: "FK_Orders_Visitors_VisitorId",
|
||||||
column: x => x.VisitorId,
|
column: x => x.VisitorId,
|
||||||
principalTable: "Visitors",
|
principalTable: "Visitors",
|
||||||
principalColumn: "Id");
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
@ -187,12 +187,14 @@ namespace CanteenDatabaseImplement.Migrations
|
|||||||
name: "FK_DishProduct_Dishes_DishId",
|
name: "FK_DishProduct_Dishes_DishId",
|
||||||
column: x => x.DishId,
|
column: x => x.DishId,
|
||||||
principalTable: "Dishes",
|
principalTable: "Dishes",
|
||||||
principalColumn: "Id");
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
table.ForeignKey(
|
table.ForeignKey(
|
||||||
name: "FK_DishProduct_Products_ProductId",
|
name: "FK_DishProduct_Products_ProductId",
|
||||||
column: x => x.ProductId,
|
column: x => x.ProductId,
|
||||||
principalTable: "Products",
|
principalTable: "Products",
|
||||||
principalColumn: "Id");
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
@ -211,12 +213,14 @@ namespace CanteenDatabaseImplement.Migrations
|
|||||||
name: "FK_ProductCook_Cooks_CookId",
|
name: "FK_ProductCook_Cooks_CookId",
|
||||||
column: x => x.CookId,
|
column: x => x.CookId,
|
||||||
principalTable: "Cooks",
|
principalTable: "Cooks",
|
||||||
principalColumn: "Id");
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
table.ForeignKey(
|
table.ForeignKey(
|
||||||
name: "FK_ProductCook_Products_ProductId",
|
name: "FK_ProductCook_Products_ProductId",
|
||||||
column: x => x.ProductId,
|
column: x => x.ProductId,
|
||||||
principalTable: "Products",
|
principalTable: "Products",
|
||||||
principalColumn: "Id");
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
@ -236,12 +240,14 @@ namespace CanteenDatabaseImplement.Migrations
|
|||||||
name: "FK_LunchProduct_Lunches_LunchId",
|
name: "FK_LunchProduct_Lunches_LunchId",
|
||||||
column: x => x.LunchId,
|
column: x => x.LunchId,
|
||||||
principalTable: "Lunches",
|
principalTable: "Lunches",
|
||||||
principalColumn: "Id");
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
table.ForeignKey(
|
table.ForeignKey(
|
||||||
name: "FK_LunchProduct_Products_ProductId",
|
name: "FK_LunchProduct_Products_ProductId",
|
||||||
column: x => x.ProductId,
|
column: x => x.ProductId,
|
||||||
principalTable: "Products",
|
principalTable: "Products",
|
||||||
principalColumn: "Id");
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
@ -251,8 +257,7 @@ namespace CanteenDatabaseImplement.Migrations
|
|||||||
Id = table.Column<int>(type: "int", nullable: false)
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
LunchId = table.Column<int>(type: "int", nullable: false),
|
LunchId = table.Column<int>(type: "int", nullable: false),
|
||||||
OrderId = table.Column<int>(type: "int", nullable: false),
|
OrderId = table.Column<int>(type: "int", nullable: false)
|
||||||
CountOrders = table.Column<int>(type: "int", nullable: false)
|
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
@ -261,12 +266,14 @@ namespace CanteenDatabaseImplement.Migrations
|
|||||||
name: "FK_LunchOrder_Lunches_LunchId",
|
name: "FK_LunchOrder_Lunches_LunchId",
|
||||||
column: x => x.LunchId,
|
column: x => x.LunchId,
|
||||||
principalTable: "Lunches",
|
principalTable: "Lunches",
|
||||||
principalColumn: "Id");
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
table.ForeignKey(
|
table.ForeignKey(
|
||||||
name: "FK_LunchOrder_Orders_OrderId",
|
name: "FK_LunchOrder_Orders_OrderId",
|
||||||
column: x => x.OrderId,
|
column: x => x.OrderId,
|
||||||
principalTable: "Orders",
|
principalTable: "Orders",
|
||||||
principalColumn: "Id");
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
@ -285,12 +292,14 @@ namespace CanteenDatabaseImplement.Migrations
|
|||||||
name: "FK_OrderCook_Cooks_CookId",
|
name: "FK_OrderCook_Cooks_CookId",
|
||||||
column: x => x.CookId,
|
column: x => x.CookId,
|
||||||
principalTable: "Cooks",
|
principalTable: "Cooks",
|
||||||
principalColumn: "Id");
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
table.ForeignKey(
|
table.ForeignKey(
|
||||||
name: "FK_OrderCook_Orders_OrderId",
|
name: "FK_OrderCook_Orders_OrderId",
|
||||||
column: x => x.OrderId,
|
column: x => x.OrderId,
|
||||||
principalTable: "Orders",
|
principalTable: "Orders",
|
||||||
principalColumn: "Id");
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
@ -310,12 +319,14 @@ namespace CanteenDatabaseImplement.Migrations
|
|||||||
name: "FK_OrderTableware_Orders_OrderId",
|
name: "FK_OrderTableware_Orders_OrderId",
|
||||||
column: x => x.OrderId,
|
column: x => x.OrderId,
|
||||||
principalTable: "Orders",
|
principalTable: "Orders",
|
||||||
principalColumn: "Id");
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
table.ForeignKey(
|
table.ForeignKey(
|
||||||
name: "FK_OrderTableware_Tablewares_TablewareId",
|
name: "FK_OrderTableware_Tablewares_TablewareId",
|
||||||
column: x => x.TablewareId,
|
column: x => x.TablewareId,
|
||||||
principalTable: "Tablewares",
|
principalTable: "Tablewares",
|
||||||
principalColumn: "Id");
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
@ -141,9 +141,6 @@ namespace CanteenDatabaseImplement.Migrations
|
|||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
b.Property<int>("CountOrders")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("LunchId")
|
b.Property<int>("LunchId")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
@ -226,9 +223,6 @@ namespace CanteenDatabaseImplement.Migrations
|
|||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("nvarchar(max)");
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
b.Property<double?>("Sum")
|
|
||||||
.HasColumnType("float");
|
|
||||||
|
|
||||||
b.Property<int>("VisitorId")
|
b.Property<int>("VisitorId")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
@ -414,13 +408,13 @@ namespace CanteenDatabaseImplement.Migrations
|
|||||||
b.HasOne("CanteenDatabaseImplement.Models.Dish", "Dish")
|
b.HasOne("CanteenDatabaseImplement.Models.Dish", "Dish")
|
||||||
.WithMany("Products")
|
.WithMany("Products")
|
||||||
.HasForeignKey("DishId")
|
.HasForeignKey("DishId")
|
||||||
.OnDelete(DeleteBehavior.NoAction)
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("CanteenDatabaseImplement.Models.Product", "Product")
|
b.HasOne("CanteenDatabaseImplement.Models.Product", "Product")
|
||||||
.WithMany("Dishes")
|
.WithMany("Dishes")
|
||||||
.HasForeignKey("ProductId")
|
.HasForeignKey("ProductId")
|
||||||
.OnDelete(DeleteBehavior.NoAction)
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.Navigation("Dish");
|
b.Navigation("Dish");
|
||||||
@ -444,13 +438,13 @@ namespace CanteenDatabaseImplement.Migrations
|
|||||||
b.HasOne("CanteenDatabaseImplement.Models.Lunch", "Lunch")
|
b.HasOne("CanteenDatabaseImplement.Models.Lunch", "Lunch")
|
||||||
.WithMany("Orders")
|
.WithMany("Orders")
|
||||||
.HasForeignKey("LunchId")
|
.HasForeignKey("LunchId")
|
||||||
.OnDelete(DeleteBehavior.NoAction)
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("CanteenDatabaseImplement.Models.Order", "Order")
|
b.HasOne("CanteenDatabaseImplement.Models.Order", "Order")
|
||||||
.WithMany("Lunches")
|
.WithMany("Lunches")
|
||||||
.HasForeignKey("OrderId")
|
.HasForeignKey("OrderId")
|
||||||
.OnDelete(DeleteBehavior.NoAction)
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.Navigation("Lunch");
|
b.Navigation("Lunch");
|
||||||
@ -463,13 +457,13 @@ namespace CanteenDatabaseImplement.Migrations
|
|||||||
b.HasOne("CanteenDatabaseImplement.Models.Lunch", "Lunch")
|
b.HasOne("CanteenDatabaseImplement.Models.Lunch", "Lunch")
|
||||||
.WithMany("Products")
|
.WithMany("Products")
|
||||||
.HasForeignKey("LunchId")
|
.HasForeignKey("LunchId")
|
||||||
.OnDelete(DeleteBehavior.NoAction)
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("CanteenDatabaseImplement.Models.Product", "Product")
|
b.HasOne("CanteenDatabaseImplement.Models.Product", "Product")
|
||||||
.WithMany("Lunches")
|
.WithMany("Lunches")
|
||||||
.HasForeignKey("ProductId")
|
.HasForeignKey("ProductId")
|
||||||
.OnDelete(DeleteBehavior.NoAction)
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.Navigation("Lunch");
|
b.Navigation("Lunch");
|
||||||
@ -482,7 +476,7 @@ namespace CanteenDatabaseImplement.Migrations
|
|||||||
b.HasOne("CanteenDatabaseImplement.Models.Visitor", "Visitor")
|
b.HasOne("CanteenDatabaseImplement.Models.Visitor", "Visitor")
|
||||||
.WithMany("Orders")
|
.WithMany("Orders")
|
||||||
.HasForeignKey("VisitorId")
|
.HasForeignKey("VisitorId")
|
||||||
.OnDelete(DeleteBehavior.NoAction)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.Navigation("Visitor");
|
b.Navigation("Visitor");
|
||||||
@ -493,13 +487,13 @@ namespace CanteenDatabaseImplement.Migrations
|
|||||||
b.HasOne("CanteenDatabaseImplement.Models.Cook", "Cook")
|
b.HasOne("CanteenDatabaseImplement.Models.Cook", "Cook")
|
||||||
.WithMany("Orders")
|
.WithMany("Orders")
|
||||||
.HasForeignKey("CookId")
|
.HasForeignKey("CookId")
|
||||||
.OnDelete(DeleteBehavior.NoAction)
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("CanteenDatabaseImplement.Models.Order", "Order")
|
b.HasOne("CanteenDatabaseImplement.Models.Order", "Order")
|
||||||
.WithMany("Cooks")
|
.WithMany("Cooks")
|
||||||
.HasForeignKey("OrderId")
|
.HasForeignKey("OrderId")
|
||||||
.OnDelete(DeleteBehavior.NoAction)
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.Navigation("Cook");
|
b.Navigation("Cook");
|
||||||
@ -512,13 +506,13 @@ namespace CanteenDatabaseImplement.Migrations
|
|||||||
b.HasOne("CanteenDatabaseImplement.Models.Order", "Order")
|
b.HasOne("CanteenDatabaseImplement.Models.Order", "Order")
|
||||||
.WithMany("Tablewares")
|
.WithMany("Tablewares")
|
||||||
.HasForeignKey("OrderId")
|
.HasForeignKey("OrderId")
|
||||||
.OnDelete(DeleteBehavior.NoAction)
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("CanteenDatabaseImplement.Models.Tableware", "Tableware")
|
b.HasOne("CanteenDatabaseImplement.Models.Tableware", "Tableware")
|
||||||
.WithMany("Orders")
|
.WithMany("Orders")
|
||||||
.HasForeignKey("TablewareId")
|
.HasForeignKey("TablewareId")
|
||||||
.OnDelete(DeleteBehavior.NoAction)
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.Navigation("Order");
|
b.Navigation("Order");
|
||||||
@ -542,13 +536,13 @@ namespace CanteenDatabaseImplement.Migrations
|
|||||||
b.HasOne("CanteenDatabaseImplement.Models.Cook", "Cook")
|
b.HasOne("CanteenDatabaseImplement.Models.Cook", "Cook")
|
||||||
.WithMany("Products")
|
.WithMany("Products")
|
||||||
.HasForeignKey("CookId")
|
.HasForeignKey("CookId")
|
||||||
.OnDelete(DeleteBehavior.NoAction)
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("CanteenDatabaseImplement.Models.Product", "Product")
|
b.HasOne("CanteenDatabaseImplement.Models.Product", "Product")
|
||||||
.WithMany("Cooks")
|
.WithMany("Cooks")
|
||||||
.HasForeignKey("ProductId")
|
.HasForeignKey("ProductId")
|
||||||
.OnDelete(DeleteBehavior.NoAction)
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.Navigation("Cook");
|
b.Navigation("Cook");
|
||||||
|
@ -77,7 +77,7 @@ namespace CanteenDatabaseImplement.Models
|
|||||||
{
|
{
|
||||||
var dishProduct = context.DishProduct.Where(rec => rec.DishId == model.Id).ToList();
|
var dishProduct = context.DishProduct.Where(rec => rec.DishId == model.Id).ToList();
|
||||||
|
|
||||||
if (dishProduct.Any())
|
if (dishProduct != null && dishProduct.Count > 0)
|
||||||
{
|
{
|
||||||
context.DishProduct.RemoveRange(dishProduct.Where(rec => !model.DishProducts.ContainsKey(rec.ProductId)));
|
context.DishProduct.RemoveRange(dishProduct.Where(rec => !model.DishProducts.ContainsKey(rec.ProductId)));
|
||||||
foreach (var updateProduct in dishProduct)
|
foreach (var updateProduct in dishProduct)
|
||||||
|
@ -17,7 +17,7 @@ namespace CanteenDatabaseImplement.Models
|
|||||||
public int ProductId { get; set; }
|
public int ProductId { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public int CountProducts { get; set; }
|
public int CountProducts { get; set; }
|
||||||
public virtual Dish Dish { get; set; } = new();
|
public virtual Dish Dish { get; set; }
|
||||||
public virtual Product Product { get; set; } = new();
|
public virtual Product Product { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,16 +41,16 @@ namespace CanteenDatabaseImplement.Models
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Dictionary<int, (IOrderModel, int)>? _lunchOrders = null;
|
private Dictionary<int, IOrderModel>? _lunchOrders = null;
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public Dictionary<int, (IOrderModel, int)> LunchOrders
|
public Dictionary<int, IOrderModel> LunchOrders
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_lunchOrders == null)
|
if (_lunchOrders == null)
|
||||||
{
|
{
|
||||||
_lunchOrders = Orders.ToDictionary(record => record.OrderId, record => (record.Order as IOrderModel, record.CountOrders));
|
_lunchOrders = Orders.ToDictionary(record => record.OrderId, record => record.Order as IOrderModel);
|
||||||
}
|
}
|
||||||
return _lunchOrders;
|
return _lunchOrders;
|
||||||
}
|
}
|
||||||
@ -80,8 +80,7 @@ namespace CanteenDatabaseImplement.Models
|
|||||||
}).ToList(),
|
}).ToList(),
|
||||||
Orders = model.LunchOrders.Select(x => new LunchOrder
|
Orders = model.LunchOrders.Select(x => new LunchOrder
|
||||||
{
|
{
|
||||||
Order = context.Orders.First(y => y.Id == x.Key),
|
Order = context.Orders.First(y => y.Id == x.Key)
|
||||||
CountOrders = x.Value.Item2
|
|
||||||
}).ToList()
|
}).ToList()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -146,7 +145,6 @@ namespace CanteenDatabaseImplement.Models
|
|||||||
|
|
||||||
foreach (var updateOrder in lunchOrders)
|
foreach (var updateOrder in lunchOrders)
|
||||||
{
|
{
|
||||||
updateOrder.CountOrders = model.LunchOrders[updateOrder.OrderId].Item2;
|
|
||||||
model.LunchOrders.Remove(updateOrder.OrderId);
|
model.LunchOrders.Remove(updateOrder.OrderId);
|
||||||
}
|
}
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
@ -158,8 +156,7 @@ namespace CanteenDatabaseImplement.Models
|
|||||||
context.LunchOrder.Add(new LunchOrder
|
context.LunchOrder.Add(new LunchOrder
|
||||||
{
|
{
|
||||||
Lunch = lunch,
|
Lunch = lunch,
|
||||||
Order = context.Orders.First(x => x.Id == pp.Key),
|
Order = context.Orders.First(x => x.Id == pp.Key)
|
||||||
CountOrders = pp.Value.Item2
|
|
||||||
});
|
});
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,6 @@ namespace CanteenDatabaseImplement.Models
|
|||||||
[Required]
|
[Required]
|
||||||
public int OrderId { get; set; }
|
public int OrderId { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public int CountOrders { get; set; }
|
|
||||||
public virtual Lunch Lunch { get; set; } = new();
|
public virtual Lunch Lunch { get; set; } = new();
|
||||||
public virtual Order Order { get; set; } = new();
|
public virtual Order Order { get; set; } = new();
|
||||||
public LunchOrderViewModel GetViewModel => new()
|
public LunchOrderViewModel GetViewModel => new()
|
||||||
|
@ -19,7 +19,6 @@ namespace CanteenDatabaseImplement.Models
|
|||||||
public int VisitorId { get; private set; }
|
public int VisitorId { get; private set; }
|
||||||
[Required]
|
[Required]
|
||||||
public string Description { get; private set; } = string.Empty;
|
public string Description { get; private set; } = string.Empty;
|
||||||
public double? Sum { get; private set; }
|
|
||||||
|
|
||||||
private Dictionary<int, ICookModel>? _orderCooks = null;
|
private Dictionary<int, ICookModel>? _orderCooks = null;
|
||||||
|
|
||||||
@ -72,7 +71,6 @@ namespace CanteenDatabaseImplement.Models
|
|||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
VisitorId = model.VisitorId,
|
VisitorId = model.VisitorId,
|
||||||
Description = model.Description,
|
Description = model.Description,
|
||||||
Sum = model.Sum
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +81,6 @@ namespace CanteenDatabaseImplement.Models
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Description = model.Description;
|
Description = model.Description;
|
||||||
Sum = model.Sum;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderViewModel GetViewModel => new()
|
public OrderViewModel GetViewModel => new()
|
||||||
@ -91,14 +88,13 @@ namespace CanteenDatabaseImplement.Models
|
|||||||
Id = Id,
|
Id = Id,
|
||||||
VisitorId = VisitorId,
|
VisitorId = VisitorId,
|
||||||
Description = Description,
|
Description = Description,
|
||||||
Sum = Sum,
|
|
||||||
OrderCooks = OrderCooks,
|
OrderCooks = OrderCooks,
|
||||||
OrderTablewares = OrderTablewares
|
OrderTablewares = OrderTablewares
|
||||||
};
|
};
|
||||||
public void UpdateOrderCook(CanteenDatabase context, OrderBindingModel model)
|
public void UpdateOrderCook(CanteenDatabase context, OrderBindingModel model)
|
||||||
{
|
{
|
||||||
var orderCook = context.OrderCook.Where(rec => rec.CookId == model.Id).ToList();
|
var orderCook = context.OrderCook.Where(rec => rec.OrderId == model.Id).ToList();
|
||||||
if (orderCook != null && (orderCook.Count > 0))
|
if (orderCook.Count > 0)
|
||||||
{
|
{
|
||||||
context.OrderCook.RemoveRange(orderCook.Where(rec => !model.OrderCooks.ContainsKey(rec.CookId)));
|
context.OrderCook.RemoveRange(orderCook.Where(rec => !model.OrderCooks.ContainsKey(rec.CookId)));
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
@ -123,8 +119,8 @@ namespace CanteenDatabaseImplement.Models
|
|||||||
}
|
}
|
||||||
public void UpdateOrderTablewares(CanteenDatabase context, OrderBindingModel model)
|
public void UpdateOrderTablewares(CanteenDatabase context, OrderBindingModel model)
|
||||||
{
|
{
|
||||||
var orderTableware = context.OrderTableware.Where(rec => rec.TablewareId == model.Id).ToList();
|
var orderTableware = context.OrderTableware.Where(rec => rec.OrderId == model.Id).ToList();
|
||||||
if (orderTableware != null && (orderTableware.Count > 0))
|
if (orderTableware != null && orderTableware.Count > 0)
|
||||||
{
|
{
|
||||||
context.OrderTableware.RemoveRange(orderTableware.Where(rec => !model.OrderTablewares.ContainsKey(rec.TablewareId)));
|
context.OrderTableware.RemoveRange(orderTableware.Where(rec => !model.OrderTablewares.ContainsKey(rec.TablewareId)));
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
|
@ -79,7 +79,7 @@ namespace CanteenDatabaseImplement.Models
|
|||||||
public void UpdateProductCooks(CanteenDatabase context, ProductBindingModel model)
|
public void UpdateProductCooks(CanteenDatabase context, ProductBindingModel model)
|
||||||
{
|
{
|
||||||
var productCookers = context.ProductCook.Where(rec => rec.ProductId == model.Id).ToList();
|
var productCookers = context.ProductCook.Where(rec => rec.ProductId == model.Id).ToList();
|
||||||
if (productCookers != null)
|
if (productCookers.Count > 0)
|
||||||
{
|
{
|
||||||
context.ProductCook.RemoveRange(productCookers.Where(rec => !model.ProductCooks.ContainsKey(rec.CookId)));
|
context.ProductCook.RemoveRange(productCookers.Where(rec => !model.ProductCooks.ContainsKey(rec.CookId)));
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
|
@ -24,11 +24,11 @@ namespace CanteenDatabaseImplement.Models
|
|||||||
|
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
[ForeignKey("VisitorId")]
|
[ForeignKey("VisitorId")]
|
||||||
public virtual List<Order> Orders { get; set; } = new();
|
public virtual List<Order> Orders { get; set; }
|
||||||
[ForeignKey("VisitorId")]
|
[ForeignKey("VisitorId")]
|
||||||
public virtual List<Lunch> Lunches { get; set; } = new();
|
public virtual List<Lunch> Lunches { get; set; }
|
||||||
[ForeignKey("VisitorId")]
|
[ForeignKey("VisitorId")]
|
||||||
public virtual List<Tableware> Tablewares { get; set; } = new();
|
public virtual List<Tableware> Tablewares { get; set; }
|
||||||
public static Visitor? Create(VisitorBindingModel model)
|
public static Visitor? Create(VisitorBindingModel model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
|
@ -272,7 +272,7 @@ namespace CanteenManagerApp.Controllers
|
|||||||
return Redirect("~/Home/Enter");
|
return Redirect("~/Home/Enter");
|
||||||
}
|
}
|
||||||
ViewBag.ProductList = APIClient.GetRequest<List<ProductViewModel>>($"api/main/getproductlist?managerId={APIClient.Manager.Id}");
|
ViewBag.ProductList = APIClient.GetRequest<List<ProductViewModel>>($"api/main/getproductlist?managerId={APIClient.Manager.Id}");
|
||||||
return Redirect("~/Home/ProductList");
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
|
@ -18,16 +18,20 @@ namespace CanteenRestApi.Controllers
|
|||||||
private readonly IDishLogic _dish;
|
private readonly IDishLogic _dish;
|
||||||
private readonly IProductLogic _product;
|
private readonly IProductLogic _product;
|
||||||
private readonly ITablewareLogic _tableware;
|
private readonly ITablewareLogic _tableware;
|
||||||
|
private readonly IOrderLogic _order;
|
||||||
|
private readonly ILunchLogic _lunch;
|
||||||
private readonly IGraphicLogic _gl;
|
private readonly IGraphicLogic _gl;
|
||||||
|
|
||||||
public MainController(ILogger<MainController> logger, ICookLogic cook, IDishLogic dish, IProductLogic product, ITablewareLogic tableware, IGraphicLogic gl)
|
public MainController(ILogger<MainController> logger, ICookLogic cook, IDishLogic dish, IProductLogic product, ITablewareLogic tableware, IOrderLogic order, IGraphicLogic gl, ILunchLogic lunch)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_cook = cook;
|
_cook = cook;
|
||||||
_dish = dish;
|
_dish = dish;
|
||||||
_product = product;
|
_product = product;
|
||||||
_tableware = tableware;
|
_tableware = tableware;
|
||||||
|
_order = order;
|
||||||
_gl = gl;
|
_gl = gl;
|
||||||
|
_lunch = lunch;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
@ -95,6 +99,19 @@ namespace CanteenRestApi.Controllers
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public List<CookViewModel>? GetCookFullList()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _cook.ReadList(null);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error during loading list of bouquets");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void CookCreate(CookBindingModel model)
|
public void CookCreate(CookBindingModel model)
|
||||||
{
|
{
|
||||||
@ -226,6 +243,19 @@ namespace CanteenRestApi.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
|
public List<ProductViewModel>? GetProductFullList()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _product.ReadList(null);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error during loading list of bouquets");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
public ProductViewModel? GetProduct(int Id)
|
public ProductViewModel? GetProduct(int Id)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -291,6 +321,175 @@ namespace CanteenRestApi.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
|
public List<OrderViewModel>? GetOrderList(int visitorId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _order.ReadList(new OrderSearchModel { VisitorId = visitorId });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error during loading list of bouquets");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public OrderViewModel? GetOrder(int Id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _order.ReadElement(new OrderSearchModel { Id = Id });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error during loading list of bouquets");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void CreateOrder(OrderBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_order.Create(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error during loading list of bouquets");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void DeleteOrder(OrderBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_order.Delete(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error during loading list of bouquets");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void UpdateOrder(OrderBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_order.Update(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error during loading list of bouquets");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void OrderAddTablewares(Tuple<OrderBindingModel, TablewareBindingModel, int> model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_order.UpdateTablewares(model.Item1, model.Item2, model.Item3);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error during loading list of bouquets");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void OrderAddCooks(Tuple<OrderBindingModel, CookBindingModel> model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_order.UpdateCooks(model.Item1, model.Item2);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error during loading list of bouquets");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void CreateLunch(LunchBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_lunch.Create(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error during loading list of bouquets");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void DeleteLunch(LunchBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_lunch.Delete(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error during loading list of bouquets");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void UpdateLunch(LunchBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_lunch.Update(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error during loading list of bouquets");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void LunchAddOrders(Tuple<LunchBindingModel, OrderBindingModel> model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_lunch.UpdateOrders(model.Item1, model.Item2);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error during loading list of bouquets");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void LunchAddProducts(Tuple<LunchBindingModel, ProductBindingModel, int> model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_lunch.UpdateProducts(model.Item1, model.Item2, model.Item3);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error during loading list of bouquets");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public List<LunchViewModel>? GetLunchList(int visitorId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _lunch.ReadList(new LunchSearchModel { VisitorId = visitorId });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error during loading list of bouquets");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
public GraphicViewModel[] GetGraphic()
|
public GraphicViewModel[] GetGraphic()
|
||||||
{
|
{
|
||||||
return new GraphicViewModel[]
|
return new GraphicViewModel[]
|
||||||
|
@ -16,6 +16,8 @@ builder.Services.AddTransient<ICookStorage, CookStorage>();
|
|||||||
builder.Services.AddTransient<IProductStorage, ProductStorage>();
|
builder.Services.AddTransient<IProductStorage, ProductStorage>();
|
||||||
builder.Services.AddTransient<IDishStorage, DishStorage>();
|
builder.Services.AddTransient<IDishStorage, DishStorage>();
|
||||||
builder.Services.AddTransient<ITablewareStorage, TablewareStorage>();
|
builder.Services.AddTransient<ITablewareStorage, TablewareStorage>();
|
||||||
|
builder.Services.AddTransient<IOrderStorage, OrderStorage>();
|
||||||
|
builder.Services.AddTransient<ILunchStorage, LunchStorage>();
|
||||||
|
|
||||||
builder.Services.AddTransient<IManagerLogic, ManagerLogic>();
|
builder.Services.AddTransient<IManagerLogic, ManagerLogic>();
|
||||||
builder.Services.AddTransient<IVisitorLogic, VisitorLogic>();
|
builder.Services.AddTransient<IVisitorLogic, VisitorLogic>();
|
||||||
@ -23,7 +25,9 @@ builder.Services.AddTransient<ICookLogic, CookLogic>();
|
|||||||
builder.Services.AddTransient<IProductLogic, ProductLogic>();
|
builder.Services.AddTransient<IProductLogic, ProductLogic>();
|
||||||
builder.Services.AddTransient<IDishLogic, DishLogic>();
|
builder.Services.AddTransient<IDishLogic, DishLogic>();
|
||||||
builder.Services.AddTransient<ITablewareLogic, TablewareLogic>();
|
builder.Services.AddTransient<ITablewareLogic, TablewareLogic>();
|
||||||
|
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
|
||||||
builder.Services.AddTransient<IGraphicLogic, GraphicLogic>();
|
builder.Services.AddTransient<IGraphicLogic, GraphicLogic>();
|
||||||
|
builder.Services.AddTransient<ILunchLogic, LunchLogic>();
|
||||||
builder.Services.AddControllers();
|
builder.Services.AddControllers();
|
||||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||||
builder.Services.AddEndpointsApiExplorer();
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
|
@ -15,7 +15,6 @@ namespace CanteenVisitorApp.Controllers
|
|||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult Index()
|
public IActionResult Index()
|
||||||
{
|
{
|
||||||
@ -26,7 +25,6 @@ namespace CanteenVisitorApp.Controllers
|
|||||||
|
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult Enter()
|
public IActionResult Enter()
|
||||||
{
|
{
|
||||||
@ -48,13 +46,11 @@ namespace CanteenVisitorApp.Controllers
|
|||||||
|
|
||||||
Response.Redirect("Index");
|
Response.Redirect("Index");
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult Register()
|
public IActionResult Register()
|
||||||
{
|
{
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void Register(string login, string password, string fio, string phoneNumber)
|
public void Register(string login, string password, string fio, string phoneNumber)
|
||||||
{
|
{
|
||||||
@ -73,7 +69,7 @@ namespace CanteenVisitorApp.Controllers
|
|||||||
|
|
||||||
Response.Redirect("Enter");
|
Response.Redirect("Enter");
|
||||||
}
|
}
|
||||||
|
[HttpGet]
|
||||||
public IActionResult Privacy()
|
public IActionResult Privacy()
|
||||||
{
|
{
|
||||||
return View();
|
return View();
|
||||||
@ -88,7 +84,6 @@ namespace CanteenVisitorApp.Controllers
|
|||||||
ViewBag.Tablewares = APIClient.GetRequest<List<TablewareViewModel>>($"api/main/gettablewarelist?visitorId={APIClient.Visitor.Id}");
|
ViewBag.Tablewares = APIClient.GetRequest<List<TablewareViewModel>>($"api/main/gettablewarelist?visitorId={APIClient.Visitor.Id}");
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult CreateTableware()
|
public IActionResult CreateTableware()
|
||||||
{
|
{
|
||||||
@ -98,7 +93,6 @@ namespace CanteenVisitorApp.Controllers
|
|||||||
}
|
}
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void CreateTableware(string tablewarename)
|
public void CreateTableware(string tablewarename)
|
||||||
{
|
{
|
||||||
@ -116,7 +110,6 @@ namespace CanteenVisitorApp.Controllers
|
|||||||
|
|
||||||
Response.Redirect("Tablewares");
|
Response.Redirect("Tablewares");
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult DeleteTableware()
|
public IActionResult DeleteTableware()
|
||||||
{
|
{
|
||||||
@ -155,7 +148,6 @@ namespace CanteenVisitorApp.Controllers
|
|||||||
ViewBag.Tablewares = APIClient.GetRequest<List<TablewareViewModel>>($"api/main/gettablewarelist?visitorId={APIClient.Visitor.Id}");
|
ViewBag.Tablewares = APIClient.GetRequest<List<TablewareViewModel>>($"api/main/gettablewarelist?visitorId={APIClient.Visitor.Id}");
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void UpdateTableware(int id, string tablewarename)
|
public void UpdateTableware(int id, string tablewarename)
|
||||||
{
|
{
|
||||||
@ -181,7 +173,6 @@ namespace CanteenVisitorApp.Controllers
|
|||||||
ViewBag.Orders = APIClient.GetRequest<List<OrderViewModel>>($"api/main/getorderlist?visitorId={APIClient.Visitor.Id}");
|
ViewBag.Orders = APIClient.GetRequest<List<OrderViewModel>>($"api/main/getorderlist?visitorId={APIClient.Visitor.Id}");
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult CreateOrder()
|
public IActionResult CreateOrder()
|
||||||
{
|
{
|
||||||
@ -191,25 +182,22 @@ namespace CanteenVisitorApp.Controllers
|
|||||||
}
|
}
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void CreateOrder(string ordername)
|
public void CreateOrder(string description)
|
||||||
{
|
{
|
||||||
if (APIClient.Visitor == null)
|
if (APIClient.Visitor == null)
|
||||||
{
|
{
|
||||||
throw new Exception("Доступ возможен только авторизованным пользователям");
|
throw new Exception("Доступ возможен только авторизованным пользователям");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
APIClient.PostRequest("api/main/createorder", new OrderBindingModel
|
APIClient.PostRequest("api/main/createorder", new OrderBindingModel
|
||||||
{
|
{
|
||||||
VisitorId = APIClient.Visitor.Id,
|
VisitorId = APIClient.Visitor.Id,
|
||||||
OrderName = ordername
|
Description = description
|
||||||
});
|
});
|
||||||
|
|
||||||
Response.Redirect("Orders");
|
Response.Redirect("Orders");
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult DeleteOrder()
|
public IActionResult DeleteOrder()
|
||||||
{
|
{
|
||||||
@ -229,7 +217,7 @@ namespace CanteenVisitorApp.Controllers
|
|||||||
}
|
}
|
||||||
if (id <= 0)
|
if (id <= 0)
|
||||||
{
|
{
|
||||||
throw new Exception("Выберите пhb,jh");
|
throw new Exception("Выберите заказ");
|
||||||
}
|
}
|
||||||
APIClient.PostRequest("api/main/DeleteOrder", new OrderBindingModel
|
APIClient.PostRequest("api/main/DeleteOrder", new OrderBindingModel
|
||||||
{
|
{
|
||||||
@ -248,21 +236,262 @@ namespace CanteenVisitorApp.Controllers
|
|||||||
ViewBag.Orders = APIClient.GetRequest<List<OrderViewModel>>($"api/main/getorderlist?visitorId={APIClient.Visitor.Id}");
|
ViewBag.Orders = APIClient.GetRequest<List<OrderViewModel>>($"api/main/getorderlist?visitorId={APIClient.Visitor.Id}");
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void UpdateOrder(int id, string ordername)
|
public void UpdateOrder(int Id, string description)
|
||||||
{
|
{
|
||||||
if (APIClient.Visitor == null)
|
if (APIClient.Visitor == null)
|
||||||
{
|
{
|
||||||
throw new Exception("Доступ возможен только авторизованным пользователям");
|
throw new Exception("Доступ возможен только авторизованным пользователям");
|
||||||
}
|
}
|
||||||
APIClient.PostRequest("api/main/UpdateOrder", new OrderBindingModel
|
APIClient.PostRequest("api/main/updateorder", new OrderBindingModel
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
Description = description,
|
||||||
|
VisitorId = APIClient.Visitor.Id
|
||||||
|
});
|
||||||
|
|
||||||
|
Response.Redirect("Orders");
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult OrderAddTablewares()
|
||||||
|
{
|
||||||
|
if (APIClient.Visitor == null)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
ViewBag.OrderList = APIClient.GetRequest<List<OrderViewModel>>($"api/main/getorderlist?visitorId={APIClient.Visitor.Id}");
|
||||||
|
ViewBag.TablewareList = APIClient.GetRequest<List<TablewareViewModel>>($"api/main/gettablewarelist?visitorId={APIClient.Visitor.Id}");
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void OrderAddTablewares(int selectedOrder, int selectedTableware, int count)
|
||||||
|
{
|
||||||
|
if (APIClient.Visitor == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Доступ возможен только авторизованным пользователям");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selectedOrder <= 0)
|
||||||
|
{
|
||||||
|
throw new Exception("Должно быть выбран заказ");
|
||||||
|
}
|
||||||
|
if (selectedTableware <= 0)
|
||||||
|
{
|
||||||
|
throw new Exception("Должен быть выбран прибор");
|
||||||
|
}
|
||||||
|
if (count < -1)
|
||||||
|
{
|
||||||
|
throw new Exception("Количество прибора должно быть больше 0");
|
||||||
|
}
|
||||||
|
|
||||||
|
APIClient.PostRequest("api/main/orderaddtablewares", Tuple.Create
|
||||||
|
(
|
||||||
|
new OrderBindingModel { Id = selectedOrder },
|
||||||
|
new TablewareBindingModel { Id = selectedTableware },
|
||||||
|
count
|
||||||
|
));
|
||||||
|
|
||||||
|
Response.Redirect("Orders");
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult OrderAddCooks()
|
||||||
|
{
|
||||||
|
if (APIClient.Visitor == null)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
ViewBag.OrderList = APIClient.GetRequest<List<OrderViewModel>>($"api/main/getorderlist?visitorId={APIClient.Visitor.Id}");
|
||||||
|
//ViewBag.CookList = new List<CookViewModel>();
|
||||||
|
ViewBag.CookList = APIClient.GetRequest<List<CookViewModel>>("api/main/getcookfulllist");
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void OrderAddCooks(int selectedOrder, int selectedCook)
|
||||||
|
{
|
||||||
|
if (APIClient.Visitor == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Доступ возможен только авторизованным пользователям");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selectedOrder <= 0)
|
||||||
|
{
|
||||||
|
throw new Exception("Должно быть выбран заказ");
|
||||||
|
}
|
||||||
|
if (selectedCook <= 0)
|
||||||
|
{
|
||||||
|
throw new Exception("Должен быть выбран повар");
|
||||||
|
}
|
||||||
|
|
||||||
|
APIClient.PostRequest("api/main/OrderAddCooks", Tuple.Create
|
||||||
|
(
|
||||||
|
new OrderBindingModel { Id = selectedOrder },
|
||||||
|
new TablewareBindingModel { Id = selectedCook }
|
||||||
|
));
|
||||||
|
|
||||||
|
Response.Redirect("Orders");
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult Lunches()
|
||||||
|
{
|
||||||
|
if (APIClient.Visitor == null)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
ViewBag.Lunches = APIClient.GetRequest<List<LunchViewModel>>($"api/main/getlunchlist?visitorId={APIClient.Visitor.Id}");
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult CreateLunch()
|
||||||
|
{
|
||||||
|
if (APIClient.Visitor == null)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void CreateLunch(string name)
|
||||||
|
{
|
||||||
|
if (APIClient.Visitor == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Доступ возможен только авторизованным пользователям");
|
||||||
|
}
|
||||||
|
|
||||||
|
APIClient.PostRequest("api/main/createlunch", new LunchBindingModel
|
||||||
|
{
|
||||||
|
VisitorId = APIClient.Visitor.Id,
|
||||||
|
LunchName = name
|
||||||
|
});
|
||||||
|
|
||||||
|
Response.Redirect("Lunches");
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult DeleteLunch()
|
||||||
|
{
|
||||||
|
if (APIClient.Visitor == null)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
ViewBag.Lunches = APIClient.GetRequest<List<OrderViewModel>>($"api/main/getlunchlist?visitorId={APIClient.Visitor.Id}");
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void DeleteLunch(int id)
|
||||||
|
{
|
||||||
|
if (APIClient.Visitor == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Доступ возможен только авторизованным пользователям");
|
||||||
|
}
|
||||||
|
if (id <= 0)
|
||||||
|
{
|
||||||
|
throw new Exception("Выберите заказ");
|
||||||
|
}
|
||||||
|
APIClient.PostRequest("api/main/DeleteLunch", new LunchBindingModel
|
||||||
|
{
|
||||||
|
Id = id
|
||||||
|
});
|
||||||
|
|
||||||
|
Response.Redirect("Lunches");
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult UpdateLunch()
|
||||||
|
{
|
||||||
|
if (APIClient.Visitor == null)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
ViewBag.Lunches = APIClient.GetRequest<List<OrderViewModel>>($"api/main/getlunchlist?visitorId={APIClient.Visitor.Id}");
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void UpdateLunch(int id, string name)
|
||||||
|
{
|
||||||
|
if (APIClient.Visitor == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Доступ возможен только авторизованным пользователям");
|
||||||
|
}
|
||||||
|
APIClient.PostRequest("api/main/UpdateLunch", new LunchBindingModel
|
||||||
{
|
{
|
||||||
Id = id,
|
Id = id,
|
||||||
VisitorId = APIClient.Visitor.Id,
|
VisitorId = APIClient.Visitor.Id,
|
||||||
OrderName = ordername
|
LunchName = name
|
||||||
});
|
});
|
||||||
Response.Redirect("Orders");
|
Response.Redirect("Lunches");
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult LunchAddProducts()
|
||||||
|
{
|
||||||
|
if (APIClient.Visitor == null)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
ViewBag.LunchList = APIClient.GetRequest<List<LunchViewModel>>($"api/main/getlunchlist?visitorId={APIClient.Visitor.Id}");
|
||||||
|
ViewBag.ProductList = APIClient.GetRequest<List<ProductViewModel>>("api/main/getproductfulllist");
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void LunchAddProducts(int selectedLunch, int selectedProduct, int count)
|
||||||
|
{
|
||||||
|
if (APIClient.Visitor == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Доступ возможен только авторизованным пользователям");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selectedLunch <= 0)
|
||||||
|
{
|
||||||
|
throw new Exception("Должен быть выбран обед");
|
||||||
|
}
|
||||||
|
if (selectedProduct <= 0)
|
||||||
|
{
|
||||||
|
throw new Exception("Должен быть выбран продукт");
|
||||||
|
}
|
||||||
|
if (count <= 0)
|
||||||
|
{
|
||||||
|
throw new Exception("Количество продукта должно быть больше 0");
|
||||||
|
}
|
||||||
|
|
||||||
|
APIClient.PostRequest("api/main/lunchaddproducts", Tuple.Create
|
||||||
|
(
|
||||||
|
new LunchBindingModel { Id = selectedLunch },
|
||||||
|
new ProductBindingModel { Id = selectedProduct },
|
||||||
|
count
|
||||||
|
));
|
||||||
|
Response.Redirect("Lunches");
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult LunchAddOrders()
|
||||||
|
{
|
||||||
|
if (APIClient.Visitor == null)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
ViewBag.LunchList = APIClient.GetRequest<List<LunchViewModel>>($"api/main/getlunchlist?visitorId={APIClient.Visitor.Id}");
|
||||||
|
ViewBag.OrderList = APIClient.GetRequest<List<OrderViewModel>>($"api/main/getorderlist?visitorId={APIClient.Visitor.Id}");
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void LunchAddOrders(int selectedLunch, int selectedOrder)
|
||||||
|
{
|
||||||
|
if (APIClient.Visitor == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Доступ возможен только авторизованным пользователям");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selectedLunch <= 0)
|
||||||
|
{
|
||||||
|
throw new Exception("Должен быть выбран обед");
|
||||||
|
}
|
||||||
|
if (selectedOrder <= 0)
|
||||||
|
{
|
||||||
|
throw new Exception("Должен быть выбран заказ");
|
||||||
|
}
|
||||||
|
|
||||||
|
APIClient.PostRequest("api/main/lunchaddorders", Tuple.Create
|
||||||
|
(
|
||||||
|
new LunchBindingModel { Id = selectedLunch },
|
||||||
|
new OrderBindingModel { Id = selectedOrder }
|
||||||
|
));
|
||||||
|
Response.Redirect("Lunches");
|
||||||
}
|
}
|
||||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||||
public IActionResult Error()
|
public IActionResult Error()
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
@*
|
@{
|
||||||
@{
|
|
||||||
ViewData["Title"] = "CreateLunch";
|
ViewData["Title"] = "CreateLunch";
|
||||||
}
|
}
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
@ -17,67 +16,10 @@
|
|||||||
<input type="text" name="name" id="name" />
|
<input type="text" name="name" id="name" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
|
||||||
<div class="col-4">Продукты:</div>
|
|
||||||
<div class="col-8">
|
|
||||||
<select id="id" name="id" class="form-control" asp-items="@(new SelectList(@ViewBag.ProductList, "Id", "ProductName"))" multiple></select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-8"></div>
|
|
||||||
<div class="col-4">
|
|
||||||
<input type="submit" value="Добавить" class="btn btn-primary" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>*@
|
|
||||||
@{
|
|
||||||
ViewData["Title"] = "CreateLunch";
|
|
||||||
}
|
|
||||||
<div class="text-center">
|
|
||||||
<h2 class="display-4">Добавление обеда</h2>
|
|
||||||
</div>
|
|
||||||
<style>
|
|
||||||
.row{
|
|
||||||
margin-top: 10px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<form method="post">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-4">Название обеда:</div>
|
|
||||||
<div class="col-8">
|
|
||||||
<input type="text" name="name" id="name" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-4">Продукты:</div>
|
|
||||||
<div class="col-8">
|
|
||||||
<select id="productId" name="productId" class="form-control" asp-items="@(new SelectList(@ViewBag.ProductList, "Id", "ProductName"))"></select>
|
|
||||||
<input type="number" name="count" id="count" />
|
|
||||||
<input type="button" value="Добавить продукт" class="btn btn-primary" onclick="addProduct()" />
|
|
||||||
<ul id="productList"></ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-8"></div>
|
<div class="col-8"></div>
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
<input type="submit" value="Создать" class="btn btn-primary" />
|
<input type="submit" value="Создать" class="btn btn-primary" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<script>
|
|
||||||
var products = [];
|
|
||||||
|
|
||||||
function addProduct() {
|
|
||||||
var productId = document.getElementById("productId").value;
|
|
||||||
var productName = document.getElementById("productId").options[document.getElementById("productId").selectedIndex].text;
|
|
||||||
var count = document.getElementById("count").value;
|
|
||||||
|
|
||||||
var product = { productId: Number(productId), count: Number(count) };
|
|
||||||
products.push(product);
|
|
||||||
|
|
||||||
var listItem = document.createElement("li");
|
|
||||||
listItem.innerHTML = productName + " - " + count;
|
|
||||||
document.getElementById("productList").appendChild(listItem);
|
|
||||||
}
|
|
||||||
</script>
|
|
@ -14,7 +14,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Описание заказа:</div>
|
<div class="col-4">Описание заказа:</div>
|
||||||
<div class="col-8">
|
<div class="col-8">
|
||||||
<input type="text" name="DescriptionOrder" id="DescriptionOrder" />
|
<input type="text" name="description" id="descriptio" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Tableware";
|
ViewData["Title"] = "CreateTableware";
|
||||||
}
|
}
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<h2 class="display-4">Добавление прибора</h2>
|
<h2 class="display-4">Добавление прибора</h2>
|
||||||
|
25
Canteen/CanteenVisitorApp/Views/Home/DeleteLunch.cshtml
Normal file
25
Canteen/CanteenVisitorApp/Views/Home/DeleteLunch.cshtml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "DeleteLunch";
|
||||||
|
}
|
||||||
|
<div class="text-center">
|
||||||
|
<h2 class="display-4">Удаление заказа</h2>
|
||||||
|
</div>
|
||||||
|
<style>
|
||||||
|
.row {
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<form method="post">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">Выберите обед</div>
|
||||||
|
<div class="col-8">
|
||||||
|
<select id="id" name="id" class="form-control" asp-items="@(new SelectList(@ViewBag.Lunches, "Id", "Id"))"></select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-8"></div>
|
||||||
|
<div class="col-4">
|
||||||
|
<input type="submit" value="Удалить" class="btn btn-primary" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
@ -13,7 +13,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Выберите заказ</div>
|
<div class="col-4">Выберите заказ</div>
|
||||||
<div class="col-8">
|
<div class="col-8">
|
||||||
<select id="id" name="id" class="form-control" asp-items="@(new SelectList(@ViewBag.Orders, "Id"))"></select>
|
<select id="id" name="id" class="form-control" asp-items="@(new SelectList(@ViewBag.Orders, "Id", "Id"))"></select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
42
Canteen/CanteenVisitorApp/Views/Home/LunchAddOrders.cshtml
Normal file
42
Canteen/CanteenVisitorApp/Views/Home/LunchAddOrders.cshtml
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
@using CanteenContracts.View;
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "LunchAddOrders";
|
||||||
|
}
|
||||||
|
<div class="text-center">
|
||||||
|
<h2 class="display-4">Привязка заказа к обеду</h2>
|
||||||
|
</div>
|
||||||
|
<style>
|
||||||
|
.row {
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<form method="post">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">Обед:</div>
|
||||||
|
<div class="col-8">
|
||||||
|
<select id="selectedLunch" name="selectedLunch">
|
||||||
|
@foreach (var Lunch in ViewBag.LunchList as List<LunchViewModel>)
|
||||||
|
{
|
||||||
|
<option value="@Lunch.Id">@Lunch.LunchName</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">Заказ:</div>
|
||||||
|
<div class="col-8">
|
||||||
|
<select name="selectedOrder">
|
||||||
|
@foreach (var order in ViewBag.OrderList as List<OrderViewModel>)
|
||||||
|
{
|
||||||
|
<option value="@order.Id">@order.Id</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-8"></div>
|
||||||
|
<div class="col-4">
|
||||||
|
<input type="submit" value="Добавить" class="btn btn-primary" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
@ -5,9 +5,10 @@
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<h2>Список обедов</h2>
|
<h2>Список обедов</h2>
|
||||||
<button type="button" class="btn btn-info" onclick="location.href='@Url.Action("CreateLunch", "Home")'">Добавить обед</button>
|
<button type="button" class="btn btn-info" onclick="location.href='@Url.Action("CreateLunch", "Home")'">Добавить обед</button>
|
||||||
<button type="button" class="btn btn-danger" onclick="location.href='@Url.Action("CreateLunch", "Home")'">Удалить обед</button>
|
<button type="button" class="btn btn-danger" onclick="location.href='@Url.Action("DeleteLunch", "Home")'">Удалить обед</button>
|
||||||
<button type="button" class="btn btn-warning" onclick="location.href='@Url.Action("CreateLunch", "Home")'">Обновить обед</button>
|
<button type="button" class="btn btn-warning" onclick="location.href='@Url.Action("UpdateLunch", "Home")'">Обновить обед</button>
|
||||||
<button type="button" class="btn btn-success" onclick="location.href='@Url.Action("CreateLunch", "Home")'">Привязать заказ</button>
|
<button type="button" class="btn btn-success" onclick="location.href='@Url.Action("LunchAddOrders", "Home")'">Привязать заказ</button>
|
||||||
|
<button type="button" class="btn btn-success" onclick="location.href='@Url.Action("LunchAddProducts", "Home")'">Привязать продукт</button>
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
42
Canteen/CanteenVisitorApp/Views/Home/OrderAddCooks.cshtml
Normal file
42
Canteen/CanteenVisitorApp/Views/Home/OrderAddCooks.cshtml
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
@using CanteenContracts.View;
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "OrderAddCooks";
|
||||||
|
}
|
||||||
|
<div class="text-center">
|
||||||
|
<h2 class="display-4">Привязка повара к заказу</h2>
|
||||||
|
</div>
|
||||||
|
<style>
|
||||||
|
.row {
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<form method="post">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">Заказ:</div>
|
||||||
|
<div class="col-8">
|
||||||
|
<select id="selectedOrder" name="selectedOrder">
|
||||||
|
@foreach (var Order in ViewBag.OrderList as List<OrderViewModel>)
|
||||||
|
{
|
||||||
|
<option value="@Order.Id">@Order.Id</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">Повар:</div>
|
||||||
|
<div class="col-8">
|
||||||
|
<select id="selectedCook" name="selectedCook">
|
||||||
|
@foreach (var Cook in ViewBag.CookList as List<CookViewModel>)
|
||||||
|
{
|
||||||
|
<option value="@Cook.Id">@Cook.FIO</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-8"></div>
|
||||||
|
<div class="col-4">
|
||||||
|
<input type="submit" value="Добавить" class="btn btn-primary" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
@ -0,0 +1,48 @@
|
|||||||
|
@using CanteenContracts.View;
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "OrderAddTablewares";
|
||||||
|
}
|
||||||
|
<div class="text-center">
|
||||||
|
<h2 class="display-4">Привязка прибора к заказу</h2>
|
||||||
|
</div>
|
||||||
|
<style>
|
||||||
|
.row {
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<form method="post">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">Заказ:</div>
|
||||||
|
<div class="col-8">
|
||||||
|
<select id="selectedOrder" name="selectedOrder">
|
||||||
|
@foreach (var order in ViewBag.OrderList as List<OrderViewModel>)
|
||||||
|
{
|
||||||
|
<option value="@order.Id">@order.Id</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">Прибор:</div>
|
||||||
|
<div class="col-8">
|
||||||
|
<select name="selectedTableware">
|
||||||
|
@foreach (var tableware in ViewBag.TablewareList as List<TablewareViewModel>)
|
||||||
|
{
|
||||||
|
<option value="@tableware.Id">@tableware.TablewareName</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">Количество:</div>
|
||||||
|
<div class="col-8">
|
||||||
|
<input type="text" name="count" id="count" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-8"></div>
|
||||||
|
<div class="col-4">
|
||||||
|
<input type="submit" value="Добавить" class="btn btn-primary" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
@ -3,18 +3,17 @@
|
|||||||
}
|
}
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<h2>Список обедов</h2>
|
<h2>Список заказов</h2>
|
||||||
<button type="button" class="btn btn-info" onclick="location.href='@Url.Action("CreateOrder", "Home")'">Добавить заказ</button>
|
<button type="button" class="btn btn-info" onclick="location.href='@Url.Action("CreateOrder", "Home")'">Добавить заказ</button>
|
||||||
<button type="button" class="btn btn-danger" onclick="location.href='@Url.Action("DeleteOrder", "Home")'">Удалить заказ</button>
|
<button type="button" class="btn btn-danger" onclick="location.href='@Url.Action("DeleteOrder", "Home")'">Удалить заказ</button>
|
||||||
<button type="button" class="btn btn-warning" onclick="location.href='@Url.Action("UpdateOrder", "Home")'">Обновить заказ</button>
|
<button type="button" class="btn btn-warning" onclick="location.href='@Url.Action("UpdateOrder", "Home")'">Обновить заказ</button>
|
||||||
|
<button type="button" class="btn btn-warning" onclick="location.href='@Url.Action("OrderAddTablewares", "Home")'">Привязать прибор</button>
|
||||||
|
<button type="button" class="btn btn-warning" onclick="location.href='@Url.Action("OrderAddCooks", "Home")'">Привязать повара</button>
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Номер</th>
|
<th>Номер</th>
|
||||||
<th>Описание обеда</th>
|
<th>Описание заказа</th>
|
||||||
<th>Сумма</th>
|
|
||||||
<th>Название прибора</th>
|
|
||||||
<th>Количество прибора</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -23,9 +22,6 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>@order.Id</td>
|
<td>@order.Id</td>
|
||||||
<td>@order.Description</td>
|
<td>@order.Description</td>
|
||||||
<td>@order.Sum</td>
|
|
||||||
<td>@order.TablewareName</td>
|
|
||||||
<td>@order.CountTablewares</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
23
Canteen/CanteenVisitorApp/Views/Home/UpdateLunch.cshtml
Normal file
23
Canteen/CanteenVisitorApp/Views/Home/UpdateLunch.cshtml
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
@using Newtonsoft.Json;
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "UpdateLunch";
|
||||||
|
}
|
||||||
|
<div class="text-center">
|
||||||
|
<h2 class="display-4">Данные обеда</h2>
|
||||||
|
</div>
|
||||||
|
<form method="post">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">Заказ:</div>
|
||||||
|
<div class="col-8"><select id="Id" name="Id" class="form-control" onchange="populateFields()" asp-items="@(new SelectList(@ViewBag.Lunches, "Id", "Id"))"></select></div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">Название обеда:</div>
|
||||||
|
<div class="col-8">
|
||||||
|
<input type="text" name="name" id="name" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-8"></div>
|
||||||
|
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
|
||||||
|
</div>
|
||||||
|
</form>
|
@ -8,12 +8,12 @@
|
|||||||
<form method="post">
|
<form method="post">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Заказ:</div>
|
<div class="col-4">Заказ:</div>
|
||||||
<div class="col-8"><select id="Id" name="Id" class="form-control" onchange="populateFields()" asp-items="@(new SelectList(@ViewBag.Orders, "Id"))"></select></div>
|
<div class="col-8"><select id="Id" name="Id" class="form-control" onchange="populateFields()" asp-items="@(new SelectList(@ViewBag.Orders, "Id", "Id"))"></select></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Прибор:</div>
|
<div class="col-4">Пожелания:</div>
|
||||||
<div class="col-8">
|
<div class="col-8">
|
||||||
<select id="tablewareId" name="tablewareId" class="form-control" onchange="populateFields()" asp-items="@(new SelectList(@ViewBag.Tablewares, "Id", "TablewareName"))"></select>
|
<input type="text" name="description" id="description" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
Loading…
Reference in New Issue
Block a user