crud full complete
This commit is contained in:
parent
a15bdf9d95
commit
19fb713cb8
@ -153,67 +153,65 @@ namespace CanteenBusinessLogic.BusinessLogics
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool AddOrder(LunchOrderBindingModel model)
|
||||
public bool UpdateOrders(LunchBindingModel lunch, OrderBindingModel order)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("AddOrder. LunchId: {LunchId}. OrderId: {OrderId}. CountOrder: {CountOrder}", model.OrderId, model.LunchId, model.OrderCount);
|
||||
if (!_lunchStorage.AddOrder(model))
|
||||
var _lunch = _lunchStorage.GetElement(new LunchSearchModel { Id = lunch.Id});
|
||||
_lunch.LunchOrders[order.Id] = order as IOrderModel;
|
||||
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 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;
|
||||
}
|
||||
|
||||
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();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,16 +25,6 @@ namespace CanteenBusinessLogic.BusinessLogics
|
||||
_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)
|
||||
{
|
||||
CheckModel(model);
|
||||
@ -110,6 +100,56 @@ namespace CanteenBusinessLogic.BusinessLogics
|
||||
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)
|
||||
{
|
||||
if (model == null)
|
||||
@ -132,12 +172,7 @@ namespace CanteenBusinessLogic.BusinessLogics
|
||||
throw new ArgumentNullException("id посетителя должен быть больше 0", nameof(model.VisitorId));
|
||||
}
|
||||
|
||||
if (model.Sum <= 0)
|
||||
{
|
||||
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);
|
||||
_logger.LogInformation("Order. Description: {Description}. VisitorId: {VisitorId}. Id: {Id}", model.Description, model.VisitorId, model.Id);
|
||||
|
||||
var element = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
|
||||
if (element != null && element.Id != model.Id)
|
||||
@ -145,80 +180,5 @@ namespace CanteenBusinessLogic.BusinessLogics
|
||||
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? DateImplement { get; set; }
|
||||
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 VisitorId { get; set; }
|
||||
public string Description { get; set; } = string.Empty;
|
||||
public double? Sum { get; set; }
|
||||
public int? TablewareId { get; set; }
|
||||
public int? CountTablewares { get; set; }
|
||||
public Dictionary<int, ICookModel> OrderCooks { get; set; } = new ();
|
||||
public Dictionary<int, (ITablewareModel, int)> OrderTablewares { get; set; } = new ();
|
||||
|
@ -18,7 +18,7 @@ namespace CanteenContracts.BusinessLogicsContracts
|
||||
bool Update(LunchBindingModel model);
|
||||
bool Delete(LunchBindingModel model);
|
||||
bool Finish(LunchBindingModel model);
|
||||
bool AddProductToLunch(LunchSearchModel model, IProductModel product, int count);
|
||||
bool AddOrderToLunch(LunchSearchModel model, IOrderModel order, int count);
|
||||
bool UpdateOrders(LunchBindingModel lunch, OrderBindingModel order);
|
||||
bool UpdateProducts(LunchBindingModel lunch, ProductBindingModel product, int count);
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ namespace CanteenContracts.BusinessLogicsContracts
|
||||
bool Create(OrderBindingModel model);
|
||||
bool Delete(OrderBindingModel model);
|
||||
bool Update(OrderBindingModel model);
|
||||
bool AddTablewareToOrder(OrderTablewareBindingModel model, ITablewareModel tableware, int count);
|
||||
bool AddCooksToOrder(OrderSearchModel model, ICookModel cook);
|
||||
bool UpdateTablewares(OrderBindingModel order, TablewareBindingModel tableware, int count);
|
||||
bool UpdateCooks(OrderBindingModel order, CookBindingModel cooks);
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,5 @@ namespace CanteenContracts.StoragesContracts
|
||||
LunchViewModel? Insert(LunchBindingModel model);
|
||||
LunchViewModel? Update(LunchBindingModel model);
|
||||
LunchViewModel? Delete(LunchBindingModel model);
|
||||
bool AddOrder(LunchOrderBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ namespace CanteenContracts.View
|
||||
public DateTime DateCreate { get; set; }
|
||||
[DisplayName("Дата реализации")]
|
||||
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.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace CanteenContracts.View
|
||||
{
|
||||
@ -15,12 +16,15 @@ namespace CanteenContracts.View
|
||||
public int VisitorId { get; set; }
|
||||
[DisplayName("Описание")]
|
||||
public string Description { get; set; } = string.Empty;
|
||||
[DisplayName("Сумма")]
|
||||
public double? Sum { 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)>();
|
||||
public Dictionary<int, ICookModel> OrderCooks { get; set; }
|
||||
public Dictionary<int, (ITablewareModel, int)> OrderTablewares { get; set; }
|
||||
[DisplayName("ID заказа")]
|
||||
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 менеджера")]
|
||||
public int ManagerId { get; set; }
|
||||
|
||||
public Dictionary<int, ICookModel> ProductCooks { get; set; } = new();
|
||||
public Dictionary<int, ICookModel> ProductCooks { get; set; }
|
||||
|
||||
public ProductViewModel() { }
|
||||
[JsonConstructor]
|
||||
|
@ -11,7 +11,6 @@ namespace CanteenDataModels.Models
|
||||
{
|
||||
int VisitorId { get; }
|
||||
string Description { get; }
|
||||
double? Sum { get; }
|
||||
Dictionary<int, ICookModel> OrderCooks { get; }
|
||||
Dictionary<int, (ITablewareModel, int)> OrderTablewares { get; }
|
||||
}
|
||||
|
@ -21,83 +21,98 @@ namespace CanteenDatabaseImplement
|
||||
.HasOne(dp => dp.Dish)
|
||||
.WithMany(d => d.Products)
|
||||
.HasForeignKey(dp => dp.DishId)
|
||||
.OnDelete(DeleteBehavior.NoAction);
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
modelBuilder.Entity<DishProduct>()
|
||||
.HasOne(dp => dp.Product)
|
||||
.WithMany(p => p.Dishes)
|
||||
.HasForeignKey(dp => dp.ProductId)
|
||||
.OnDelete(DeleteBehavior.NoAction);
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
//=====================================
|
||||
|
||||
modelBuilder.Entity<LunchOrder>()
|
||||
.HasOne(dp => dp.Lunch)
|
||||
.WithMany(d => d.Orders)
|
||||
.HasForeignKey(dp => dp.LunchId)
|
||||
.OnDelete(DeleteBehavior.NoAction);
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
modelBuilder.Entity<LunchOrder>()
|
||||
.HasOne(dp => dp.Order)
|
||||
.WithMany(p => p.Lunches)
|
||||
.HasForeignKey(dp => dp.OrderId)
|
||||
.OnDelete(DeleteBehavior.NoAction);
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
//=====================================
|
||||
|
||||
modelBuilder.Entity<LunchProduct>()
|
||||
.HasOne(dp => dp.Lunch)
|
||||
.WithMany(d => d.Products)
|
||||
.HasForeignKey(dp => dp.LunchId)
|
||||
.OnDelete(DeleteBehavior.NoAction);
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
modelBuilder.Entity<LunchProduct>()
|
||||
.HasOne(dp => dp.Product)
|
||||
.WithMany(p => p.Lunches)
|
||||
.HasForeignKey(dp => dp.ProductId)
|
||||
.OnDelete(DeleteBehavior.NoAction);
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
//=====================================
|
||||
|
||||
modelBuilder.Entity<OrderCook>()
|
||||
.HasOne(dp => dp.Order)
|
||||
.WithMany(d => d.Cooks)
|
||||
.HasForeignKey(dp => dp.OrderId)
|
||||
.OnDelete(DeleteBehavior.NoAction);
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
modelBuilder.Entity<OrderCook>()
|
||||
.HasOne(dp => dp.Cook)
|
||||
.WithMany(p => p.Orders)
|
||||
.HasForeignKey(dp => dp.CookId)
|
||||
.OnDelete(DeleteBehavior.NoAction);
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
//=====================================
|
||||
|
||||
modelBuilder.Entity<OrderTableware>()
|
||||
.HasOne(dp => dp.Order)
|
||||
.WithMany(d => d.Tablewares)
|
||||
.HasForeignKey(dp => dp.OrderId)
|
||||
.OnDelete(DeleteBehavior.NoAction);
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
modelBuilder.Entity<OrderTableware>()
|
||||
.HasOne(dp => dp.Tableware)
|
||||
.WithMany(p => p.Orders)
|
||||
.HasForeignKey(dp => dp.TablewareId)
|
||||
.OnDelete(DeleteBehavior.NoAction);
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
//=====================================
|
||||
|
||||
modelBuilder.Entity<ProductCook>()
|
||||
.HasOne(dp => dp.Product)
|
||||
.WithMany(d => d.Cooks)
|
||||
.HasForeignKey(dp => dp.ProductId)
|
||||
.OnDelete(DeleteBehavior.NoAction);
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
modelBuilder.Entity<ProductCook>()
|
||||
.HasOne(dp => dp.Cook)
|
||||
.WithMany(p => p.Products)
|
||||
.HasForeignKey(dp => dp.CookId)
|
||||
.OnDelete(DeleteBehavior.NoAction);
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
//=====================================
|
||||
modelBuilder.Entity<Order>()
|
||||
.HasOne(b => b.Visitor)
|
||||
.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
|
||||
.Include(x => x.Products)
|
||||
.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()
|
||||
{
|
||||
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)
|
||||
@ -99,7 +104,7 @@ namespace CanteenDatabaseImplement.Implements
|
||||
dish.Update(model);
|
||||
|
||||
context.SaveChanges();
|
||||
dish.UpdateDishProduct(context, model);
|
||||
if (model.DishProducts.Any()) dish.UpdateDishProduct(context, model);
|
||||
context.Database.CommitTransaction();
|
||||
|
||||
return dish.GetViewModel;
|
||||
|
@ -28,6 +28,8 @@ namespace CanteenDatabaseImplement.Implements
|
||||
return context.Lunches
|
||||
.Include(x => x.Products)
|
||||
.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;
|
||||
}
|
||||
public LunchOrderViewModel? GetLunchOrderElement(LunchOrderSearchModel model)
|
||||
@ -44,7 +46,7 @@ namespace CanteenDatabaseImplement.Implements
|
||||
}
|
||||
public List<LunchViewModel> GetFilteredList(LunchSearchModel model)
|
||||
{
|
||||
if (!model.DateFrom.HasValue || !model.DateTo.HasValue)
|
||||
if (!model.VisitorId.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
@ -54,6 +56,8 @@ namespace CanteenDatabaseImplement.Implements
|
||||
return context.Lunches
|
||||
.Include(x => x.Products)
|
||||
.ThenInclude(x => x.Product)
|
||||
.Include(x => x.Orders)
|
||||
.ThenInclude(x => x.Order)
|
||||
.Where(x =>
|
||||
(x.DateCreate >= model.DateFrom && x.DateImplement <= model.DateTo) ||
|
||||
(model.Id.HasValue && x.Id == model.Id) ||
|
||||
@ -66,6 +70,8 @@ namespace CanteenDatabaseImplement.Implements
|
||||
return context.Lunches
|
||||
.Include(x => x.Products)
|
||||
.ThenInclude(x => x.Product)
|
||||
.Include(x => x.Orders)
|
||||
.ThenInclude(x => x.Order)
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
public LunchViewModel? Insert(LunchBindingModel model)
|
||||
@ -115,10 +121,8 @@ namespace CanteenDatabaseImplement.Implements
|
||||
lunch.Update(model);
|
||||
|
||||
context.SaveChanges();
|
||||
if (model.LunchProducts != null)
|
||||
lunch.UpdateProducts(context, model);
|
||||
if (model.LunchOrders != null)
|
||||
lunch.UpdateOrders(context, model);
|
||||
if (model.LunchProducts.Any()) lunch.UpdateProducts(context, model);
|
||||
if (model.LunchOrders.Any()) lunch.UpdateOrders(context, model);
|
||||
context.Database.CommitTransaction();
|
||||
|
||||
return lunch.GetViewModel;
|
||||
@ -145,30 +149,5 @@ namespace CanteenDatabaseImplement.Implements
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,10 @@ namespace CanteenDatabaseImplement.Implements
|
||||
return context.Orders
|
||||
.Include(x => x.Cooks)
|
||||
.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)
|
||||
@ -56,6 +59,8 @@ namespace CanteenDatabaseImplement.Implements
|
||||
return context.Orders
|
||||
.Include(x => x.Cooks)
|
||||
.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();
|
||||
}
|
||||
|
||||
@ -88,16 +93,18 @@ namespace CanteenDatabaseImplement.Implements
|
||||
{
|
||||
using var context = new CanteenDatabase();
|
||||
|
||||
var client = context.Orders.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (client == null)
|
||||
var order = context.Orders.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (order == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
client.Update(model);
|
||||
order.Update(model);
|
||||
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)
|
||||
|
@ -113,7 +113,7 @@ namespace CanteenDatabaseImplement.Implements
|
||||
|
||||
product.Update(model);
|
||||
context.SaveChanges();
|
||||
if (model.ProductCooks != null)
|
||||
if (model.ProductCooks.Any())
|
||||
product.UpdateProductCooks(context, model);
|
||||
context.Database.CommitTransaction();
|
||||
|
||||
|
@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
namespace CanteenDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(CanteenDatabase))]
|
||||
[Migration("20230518211530_Init")]
|
||||
[Migration("20230519185610_Init")]
|
||||
partial class Init
|
||||
{
|
||||
/// <inheritdoc />
|
||||
@ -144,9 +144,6 @@ namespace CanteenDatabaseImplement.Migrations
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CountOrders")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("LunchId")
|
||||
.HasColumnType("int");
|
||||
|
||||
@ -229,9 +226,6 @@ namespace CanteenDatabaseImplement.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double?>("Sum")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<int>("VisitorId")
|
||||
.HasColumnType("int");
|
||||
|
||||
@ -417,13 +411,13 @@ namespace CanteenDatabaseImplement.Migrations
|
||||
b.HasOne("CanteenDatabaseImplement.Models.Dish", "Dish")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("DishId")
|
||||
.OnDelete(DeleteBehavior.NoAction)
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("CanteenDatabaseImplement.Models.Product", "Product")
|
||||
.WithMany("Dishes")
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.NoAction)
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Dish");
|
||||
@ -447,13 +441,13 @@ namespace CanteenDatabaseImplement.Migrations
|
||||
b.HasOne("CanteenDatabaseImplement.Models.Lunch", "Lunch")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("LunchId")
|
||||
.OnDelete(DeleteBehavior.NoAction)
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("CanteenDatabaseImplement.Models.Order", "Order")
|
||||
.WithMany("Lunches")
|
||||
.HasForeignKey("OrderId")
|
||||
.OnDelete(DeleteBehavior.NoAction)
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Lunch");
|
||||
@ -466,13 +460,13 @@ namespace CanteenDatabaseImplement.Migrations
|
||||
b.HasOne("CanteenDatabaseImplement.Models.Lunch", "Lunch")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("LunchId")
|
||||
.OnDelete(DeleteBehavior.NoAction)
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("CanteenDatabaseImplement.Models.Product", "Product")
|
||||
.WithMany("Lunches")
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.NoAction)
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Lunch");
|
||||
@ -485,7 +479,7 @@ namespace CanteenDatabaseImplement.Migrations
|
||||
b.HasOne("CanteenDatabaseImplement.Models.Visitor", "Visitor")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("VisitorId")
|
||||
.OnDelete(DeleteBehavior.NoAction)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Visitor");
|
||||
@ -496,13 +490,13 @@ namespace CanteenDatabaseImplement.Migrations
|
||||
b.HasOne("CanteenDatabaseImplement.Models.Cook", "Cook")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("CookId")
|
||||
.OnDelete(DeleteBehavior.NoAction)
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("CanteenDatabaseImplement.Models.Order", "Order")
|
||||
.WithMany("Cooks")
|
||||
.HasForeignKey("OrderId")
|
||||
.OnDelete(DeleteBehavior.NoAction)
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Cook");
|
||||
@ -515,13 +509,13 @@ namespace CanteenDatabaseImplement.Migrations
|
||||
b.HasOne("CanteenDatabaseImplement.Models.Order", "Order")
|
||||
.WithMany("Tablewares")
|
||||
.HasForeignKey("OrderId")
|
||||
.OnDelete(DeleteBehavior.NoAction)
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("CanteenDatabaseImplement.Models.Tableware", "Tableware")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("TablewareId")
|
||||
.OnDelete(DeleteBehavior.NoAction)
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Order");
|
||||
@ -545,13 +539,13 @@ namespace CanteenDatabaseImplement.Migrations
|
||||
b.HasOne("CanteenDatabaseImplement.Models.Cook", "Cook")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("CookId")
|
||||
.OnDelete(DeleteBehavior.NoAction)
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("CanteenDatabaseImplement.Models.Product", "Product")
|
||||
.WithMany("Cooks")
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.NoAction)
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Cook");
|
@ -137,8 +137,7 @@ namespace CanteenDatabaseImplement.Migrations
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
VisitorId = table.Column<int>(type: "int", nullable: false),
|
||||
Description = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Sum = table.Column<double>(type: "float", nullable: true)
|
||||
Description = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
@ -147,7 +146,8 @@ namespace CanteenDatabaseImplement.Migrations
|
||||
name: "FK_Orders_Visitors_VisitorId",
|
||||
column: x => x.VisitorId,
|
||||
principalTable: "Visitors",
|
||||
principalColumn: "Id");
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
@ -187,12 +187,14 @@ namespace CanteenDatabaseImplement.Migrations
|
||||
name: "FK_DishProduct_Dishes_DishId",
|
||||
column: x => x.DishId,
|
||||
principalTable: "Dishes",
|
||||
principalColumn: "Id");
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "FK_DishProduct_Products_ProductId",
|
||||
column: x => x.ProductId,
|
||||
principalTable: "Products",
|
||||
principalColumn: "Id");
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
@ -211,12 +213,14 @@ namespace CanteenDatabaseImplement.Migrations
|
||||
name: "FK_ProductCook_Cooks_CookId",
|
||||
column: x => x.CookId,
|
||||
principalTable: "Cooks",
|
||||
principalColumn: "Id");
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "FK_ProductCook_Products_ProductId",
|
||||
column: x => x.ProductId,
|
||||
principalTable: "Products",
|
||||
principalColumn: "Id");
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
@ -236,12 +240,14 @@ namespace CanteenDatabaseImplement.Migrations
|
||||
name: "FK_LunchProduct_Lunches_LunchId",
|
||||
column: x => x.LunchId,
|
||||
principalTable: "Lunches",
|
||||
principalColumn: "Id");
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "FK_LunchProduct_Products_ProductId",
|
||||
column: x => x.ProductId,
|
||||
principalTable: "Products",
|
||||
principalColumn: "Id");
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
@ -251,8 +257,7 @@ namespace CanteenDatabaseImplement.Migrations
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
LunchId = table.Column<int>(type: "int", nullable: false),
|
||||
OrderId = table.Column<int>(type: "int", nullable: false),
|
||||
CountOrders = table.Column<int>(type: "int", nullable: false)
|
||||
OrderId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
@ -261,12 +266,14 @@ namespace CanteenDatabaseImplement.Migrations
|
||||
name: "FK_LunchOrder_Lunches_LunchId",
|
||||
column: x => x.LunchId,
|
||||
principalTable: "Lunches",
|
||||
principalColumn: "Id");
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "FK_LunchOrder_Orders_OrderId",
|
||||
column: x => x.OrderId,
|
||||
principalTable: "Orders",
|
||||
principalColumn: "Id");
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
@ -285,12 +292,14 @@ namespace CanteenDatabaseImplement.Migrations
|
||||
name: "FK_OrderCook_Cooks_CookId",
|
||||
column: x => x.CookId,
|
||||
principalTable: "Cooks",
|
||||
principalColumn: "Id");
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "FK_OrderCook_Orders_OrderId",
|
||||
column: x => x.OrderId,
|
||||
principalTable: "Orders",
|
||||
principalColumn: "Id");
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
@ -310,12 +319,14 @@ namespace CanteenDatabaseImplement.Migrations
|
||||
name: "FK_OrderTableware_Orders_OrderId",
|
||||
column: x => x.OrderId,
|
||||
principalTable: "Orders",
|
||||
principalColumn: "Id");
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "FK_OrderTableware_Tablewares_TablewareId",
|
||||
column: x => x.TablewareId,
|
||||
principalTable: "Tablewares",
|
||||
principalColumn: "Id");
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
@ -141,9 +141,6 @@ namespace CanteenDatabaseImplement.Migrations
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CountOrders")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("LunchId")
|
||||
.HasColumnType("int");
|
||||
|
||||
@ -226,9 +223,6 @@ namespace CanteenDatabaseImplement.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double?>("Sum")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<int>("VisitorId")
|
||||
.HasColumnType("int");
|
||||
|
||||
@ -414,13 +408,13 @@ namespace CanteenDatabaseImplement.Migrations
|
||||
b.HasOne("CanteenDatabaseImplement.Models.Dish", "Dish")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("DishId")
|
||||
.OnDelete(DeleteBehavior.NoAction)
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("CanteenDatabaseImplement.Models.Product", "Product")
|
||||
.WithMany("Dishes")
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.NoAction)
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Dish");
|
||||
@ -444,13 +438,13 @@ namespace CanteenDatabaseImplement.Migrations
|
||||
b.HasOne("CanteenDatabaseImplement.Models.Lunch", "Lunch")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("LunchId")
|
||||
.OnDelete(DeleteBehavior.NoAction)
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("CanteenDatabaseImplement.Models.Order", "Order")
|
||||
.WithMany("Lunches")
|
||||
.HasForeignKey("OrderId")
|
||||
.OnDelete(DeleteBehavior.NoAction)
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Lunch");
|
||||
@ -463,13 +457,13 @@ namespace CanteenDatabaseImplement.Migrations
|
||||
b.HasOne("CanteenDatabaseImplement.Models.Lunch", "Lunch")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("LunchId")
|
||||
.OnDelete(DeleteBehavior.NoAction)
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("CanteenDatabaseImplement.Models.Product", "Product")
|
||||
.WithMany("Lunches")
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.NoAction)
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Lunch");
|
||||
@ -482,7 +476,7 @@ namespace CanteenDatabaseImplement.Migrations
|
||||
b.HasOne("CanteenDatabaseImplement.Models.Visitor", "Visitor")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("VisitorId")
|
||||
.OnDelete(DeleteBehavior.NoAction)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Visitor");
|
||||
@ -493,13 +487,13 @@ namespace CanteenDatabaseImplement.Migrations
|
||||
b.HasOne("CanteenDatabaseImplement.Models.Cook", "Cook")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("CookId")
|
||||
.OnDelete(DeleteBehavior.NoAction)
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("CanteenDatabaseImplement.Models.Order", "Order")
|
||||
.WithMany("Cooks")
|
||||
.HasForeignKey("OrderId")
|
||||
.OnDelete(DeleteBehavior.NoAction)
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Cook");
|
||||
@ -512,13 +506,13 @@ namespace CanteenDatabaseImplement.Migrations
|
||||
b.HasOne("CanteenDatabaseImplement.Models.Order", "Order")
|
||||
.WithMany("Tablewares")
|
||||
.HasForeignKey("OrderId")
|
||||
.OnDelete(DeleteBehavior.NoAction)
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("CanteenDatabaseImplement.Models.Tableware", "Tableware")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("TablewareId")
|
||||
.OnDelete(DeleteBehavior.NoAction)
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Order");
|
||||
@ -542,13 +536,13 @@ namespace CanteenDatabaseImplement.Migrations
|
||||
b.HasOne("CanteenDatabaseImplement.Models.Cook", "Cook")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("CookId")
|
||||
.OnDelete(DeleteBehavior.NoAction)
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("CanteenDatabaseImplement.Models.Product", "Product")
|
||||
.WithMany("Cooks")
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.NoAction)
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Cook");
|
||||
|
@ -77,7 +77,7 @@ namespace CanteenDatabaseImplement.Models
|
||||
{
|
||||
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)));
|
||||
foreach (var updateProduct in dishProduct)
|
||||
|
@ -17,7 +17,7 @@ namespace CanteenDatabaseImplement.Models
|
||||
public int ProductId { get; set; }
|
||||
[Required]
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -41,16 +41,16 @@ namespace CanteenDatabaseImplement.Models
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<int, (IOrderModel, int)>? _lunchOrders = null;
|
||||
private Dictionary<int, IOrderModel>? _lunchOrders = null;
|
||||
|
||||
[NotMapped]
|
||||
public Dictionary<int, (IOrderModel, int)> LunchOrders
|
||||
public Dictionary<int, IOrderModel> LunchOrders
|
||||
{
|
||||
get
|
||||
{
|
||||
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;
|
||||
}
|
||||
@ -80,8 +80,7 @@ namespace CanteenDatabaseImplement.Models
|
||||
}).ToList(),
|
||||
Orders = model.LunchOrders.Select(x => new LunchOrder
|
||||
{
|
||||
Order = context.Orders.First(y => y.Id == x.Key),
|
||||
CountOrders = x.Value.Item2
|
||||
Order = context.Orders.First(y => y.Id == x.Key)
|
||||
}).ToList()
|
||||
};
|
||||
}
|
||||
@ -146,7 +145,6 @@ namespace CanteenDatabaseImplement.Models
|
||||
|
||||
foreach (var updateOrder in lunchOrders)
|
||||
{
|
||||
updateOrder.CountOrders = model.LunchOrders[updateOrder.OrderId].Item2;
|
||||
model.LunchOrders.Remove(updateOrder.OrderId);
|
||||
}
|
||||
context.SaveChanges();
|
||||
@ -158,8 +156,7 @@ namespace CanteenDatabaseImplement.Models
|
||||
context.LunchOrder.Add(new LunchOrder
|
||||
{
|
||||
Lunch = lunch,
|
||||
Order = context.Orders.First(x => x.Id == pp.Key),
|
||||
CountOrders = pp.Value.Item2
|
||||
Order = context.Orders.First(x => x.Id == pp.Key)
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ namespace CanteenDatabaseImplement.Models
|
||||
[Required]
|
||||
public int OrderId { get; set; }
|
||||
[Required]
|
||||
public int CountOrders { get; set; }
|
||||
public virtual Lunch Lunch { get; set; } = new();
|
||||
public virtual Order Order { get; set; } = new();
|
||||
public LunchOrderViewModel GetViewModel => new()
|
||||
|
@ -19,7 +19,6 @@ namespace CanteenDatabaseImplement.Models
|
||||
public int VisitorId { get; private set; }
|
||||
[Required]
|
||||
public string Description { get; private set; } = string.Empty;
|
||||
public double? Sum { get; private set; }
|
||||
|
||||
private Dictionary<int, ICookModel>? _orderCooks = null;
|
||||
|
||||
@ -72,7 +71,6 @@ namespace CanteenDatabaseImplement.Models
|
||||
Id = model.Id,
|
||||
VisitorId = model.VisitorId,
|
||||
Description = model.Description,
|
||||
Sum = model.Sum
|
||||
};
|
||||
}
|
||||
|
||||
@ -83,7 +81,6 @@ namespace CanteenDatabaseImplement.Models
|
||||
return;
|
||||
}
|
||||
Description = model.Description;
|
||||
Sum = model.Sum;
|
||||
}
|
||||
|
||||
public OrderViewModel GetViewModel => new()
|
||||
@ -91,14 +88,13 @@ namespace CanteenDatabaseImplement.Models
|
||||
Id = Id,
|
||||
VisitorId = VisitorId,
|
||||
Description = Description,
|
||||
Sum = Sum,
|
||||
OrderCooks = OrderCooks,
|
||||
OrderTablewares = OrderTablewares
|
||||
};
|
||||
public void UpdateOrderCook(CanteenDatabase context, OrderBindingModel model)
|
||||
{
|
||||
var orderCook = context.OrderCook.Where(rec => rec.CookId == model.Id).ToList();
|
||||
if (orderCook != null && (orderCook.Count > 0))
|
||||
var orderCook = context.OrderCook.Where(rec => rec.OrderId == model.Id).ToList();
|
||||
if (orderCook.Count > 0)
|
||||
{
|
||||
context.OrderCook.RemoveRange(orderCook.Where(rec => !model.OrderCooks.ContainsKey(rec.CookId)));
|
||||
context.SaveChanges();
|
||||
@ -123,8 +119,8 @@ namespace CanteenDatabaseImplement.Models
|
||||
}
|
||||
public void UpdateOrderTablewares(CanteenDatabase context, OrderBindingModel model)
|
||||
{
|
||||
var orderTableware = context.OrderTableware.Where(rec => rec.TablewareId == model.Id).ToList();
|
||||
if (orderTableware != null && (orderTableware.Count > 0))
|
||||
var orderTableware = context.OrderTableware.Where(rec => rec.OrderId == model.Id).ToList();
|
||||
if (orderTableware != null && orderTableware.Count > 0)
|
||||
{
|
||||
context.OrderTableware.RemoveRange(orderTableware.Where(rec => !model.OrderTablewares.ContainsKey(rec.TablewareId)));
|
||||
context.SaveChanges();
|
||||
|
@ -79,7 +79,7 @@ namespace CanteenDatabaseImplement.Models
|
||||
public void UpdateProductCooks(CanteenDatabase context, ProductBindingModel model)
|
||||
{
|
||||
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.SaveChanges();
|
||||
|
@ -24,11 +24,11 @@ namespace CanteenDatabaseImplement.Models
|
||||
|
||||
public int Id { get; private set; }
|
||||
[ForeignKey("VisitorId")]
|
||||
public virtual List<Order> Orders { get; set; } = new();
|
||||
public virtual List<Order> Orders { get; set; }
|
||||
[ForeignKey("VisitorId")]
|
||||
public virtual List<Lunch> Lunches { get; set; } = new();
|
||||
public virtual List<Lunch> Lunches { get; set; }
|
||||
[ForeignKey("VisitorId")]
|
||||
public virtual List<Tableware> Tablewares { get; set; } = new();
|
||||
public virtual List<Tableware> Tablewares { get; set; }
|
||||
public static Visitor? Create(VisitorBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
|
@ -272,7 +272,7 @@ namespace CanteenManagerApp.Controllers
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.ProductList = APIClient.GetRequest<List<ProductViewModel>>($"api/main/getproductlist?managerId={APIClient.Manager.Id}");
|
||||
return Redirect("~/Home/ProductList");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
|
@ -18,16 +18,20 @@ namespace CanteenRestApi.Controllers
|
||||
private readonly IDishLogic _dish;
|
||||
private readonly IProductLogic _product;
|
||||
private readonly ITablewareLogic _tableware;
|
||||
private readonly IOrderLogic _order;
|
||||
private readonly ILunchLogic _lunch;
|
||||
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;
|
||||
_cook = cook;
|
||||
_dish = dish;
|
||||
_product = product;
|
||||
_tableware = tableware;
|
||||
_order = order;
|
||||
_gl = gl;
|
||||
_lunch = lunch;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
@ -95,6 +99,19 @@ namespace CanteenRestApi.Controllers
|
||||
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]
|
||||
public void CookCreate(CookBindingModel model)
|
||||
{
|
||||
@ -226,6 +243,19 @@ namespace CanteenRestApi.Controllers
|
||||
}
|
||||
}
|
||||
[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)
|
||||
{
|
||||
try
|
||||
@ -291,6 +321,175 @@ namespace CanteenRestApi.Controllers
|
||||
}
|
||||
}
|
||||
[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()
|
||||
{
|
||||
return new GraphicViewModel[]
|
||||
|
@ -16,6 +16,8 @@ builder.Services.AddTransient<ICookStorage, CookStorage>();
|
||||
builder.Services.AddTransient<IProductStorage, ProductStorage>();
|
||||
builder.Services.AddTransient<IDishStorage, DishStorage>();
|
||||
builder.Services.AddTransient<ITablewareStorage, TablewareStorage>();
|
||||
builder.Services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
builder.Services.AddTransient<ILunchStorage, LunchStorage>();
|
||||
|
||||
builder.Services.AddTransient<IManagerLogic, ManagerLogic>();
|
||||
builder.Services.AddTransient<IVisitorLogic, VisitorLogic>();
|
||||
@ -23,7 +25,9 @@ builder.Services.AddTransient<ICookLogic, CookLogic>();
|
||||
builder.Services.AddTransient<IProductLogic, ProductLogic>();
|
||||
builder.Services.AddTransient<IDishLogic, DishLogic>();
|
||||
builder.Services.AddTransient<ITablewareLogic, TablewareLogic>();
|
||||
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
builder.Services.AddTransient<IGraphicLogic, GraphicLogic>();
|
||||
builder.Services.AddTransient<ILunchLogic, LunchLogic>();
|
||||
builder.Services.AddControllers();
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
|
@ -15,7 +15,6 @@ namespace CanteenVisitorApp.Controllers
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Index()
|
||||
{
|
||||
@ -26,7 +25,6 @@ namespace CanteenVisitorApp.Controllers
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Enter()
|
||||
{
|
||||
@ -48,13 +46,11 @@ namespace CanteenVisitorApp.Controllers
|
||||
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Register()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Register(string login, string password, string fio, string phoneNumber)
|
||||
{
|
||||
@ -73,7 +69,7 @@ namespace CanteenVisitorApp.Controllers
|
||||
|
||||
Response.Redirect("Enter");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Privacy()
|
||||
{
|
||||
return View();
|
||||
@ -88,7 +84,6 @@ namespace CanteenVisitorApp.Controllers
|
||||
ViewBag.Tablewares = APIClient.GetRequest<List<TablewareViewModel>>($"api/main/gettablewarelist?visitorId={APIClient.Visitor.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult CreateTableware()
|
||||
{
|
||||
@ -98,7 +93,6 @@ namespace CanteenVisitorApp.Controllers
|
||||
}
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateTableware(string tablewarename)
|
||||
{
|
||||
@ -116,7 +110,6 @@ namespace CanteenVisitorApp.Controllers
|
||||
|
||||
Response.Redirect("Tablewares");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult DeleteTableware()
|
||||
{
|
||||
@ -155,7 +148,6 @@ namespace CanteenVisitorApp.Controllers
|
||||
ViewBag.Tablewares = APIClient.GetRequest<List<TablewareViewModel>>($"api/main/gettablewarelist?visitorId={APIClient.Visitor.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
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}");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult CreateOrder()
|
||||
{
|
||||
@ -191,25 +182,22 @@ namespace CanteenVisitorApp.Controllers
|
||||
}
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateOrder(string ordername)
|
||||
public void CreateOrder(string description)
|
||||
{
|
||||
if (APIClient.Visitor == null)
|
||||
{
|
||||
throw new Exception("Доступ возможен только авторизованным пользователям");
|
||||
}
|
||||
|
||||
|
||||
APIClient.PostRequest("api/main/createorder", new OrderBindingModel
|
||||
{
|
||||
VisitorId = APIClient.Visitor.Id,
|
||||
OrderName = ordername
|
||||
Description = description
|
||||
});
|
||||
|
||||
Response.Redirect("Orders");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult DeleteOrder()
|
||||
{
|
||||
@ -229,7 +217,7 @@ namespace CanteenVisitorApp.Controllers
|
||||
}
|
||||
if (id <= 0)
|
||||
{
|
||||
throw new Exception("Выберите пhb,jh");
|
||||
throw new Exception("Выберите заказ");
|
||||
}
|
||||
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}");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateOrder(int id, string ordername)
|
||||
public void UpdateOrder(int Id, string description)
|
||||
{
|
||||
if (APIClient.Visitor == null)
|
||||
{
|
||||
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,
|
||||
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)]
|
||||
public IActionResult Error()
|
||||
|
@ -1,5 +1,4 @@
|
||||
@*
|
||||
@{
|
||||
@{
|
||||
ViewData["Title"] = "CreateLunch";
|
||||
}
|
||||
<div class="text-center">
|
||||
@ -17,46 +16,6 @@
|
||||
<input type="text" name="name" id="name" />
|
||||
</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="col-8"></div>
|
||||
<div class="col-4">
|
||||
@ -64,20 +23,3 @@
|
||||
</div>
|
||||
</div>
|
||||
</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="col-4">Описание заказа:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="DescriptionOrder" id="DescriptionOrder" />
|
||||
<input type="text" name="description" id="descriptio" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Tableware";
|
||||
ViewData["Title"] = "CreateTableware";
|
||||
}
|
||||
<div class="text-center">
|
||||
<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="col-4">Выберите заказ</div>
|
||||
<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 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">
|
||||
<h2>Список обедов</h2>
|
||||
<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-warning" onclick="location.href='@Url.Action("CreateLunch", "Home")'">Обновить обед</button>
|
||||
<button type="button" class="btn btn-success" 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("UpdateLunch", "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">
|
||||
<thead>
|
||||
<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>
|
||||
<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-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("OrderAddTablewares", "Home")'">Привязать прибор</button>
|
||||
<button type="button" class="btn btn-warning" onclick="location.href='@Url.Action("OrderAddCooks", "Home")'">Привязать повара</button>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Номер</th>
|
||||
<th>Описание обеда</th>
|
||||
<th>Сумма</th>
|
||||
<th>Название прибора</th>
|
||||
<th>Количество прибора</th>
|
||||
<th>Описание заказа</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -23,9 +22,6 @@
|
||||
<tr>
|
||||
<td>@order.Id</td>
|
||||
<td>@order.Description</td>
|
||||
<td>@order.Sum</td>
|
||||
<td>@order.TablewareName</td>
|
||||
<td>@order.CountTablewares</td>
|
||||
</tr>
|
||||
}
|
||||
</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">
|
||||
<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.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 class="row">
|
||||
<div class="col-4">Прибор:</div>
|
||||
<div class="col-4">Пожелания:</div>
|
||||
<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 class="row">
|
||||
|
Loading…
Reference in New Issue
Block a user