public async Task <IViewComponentResult> InvokeAsync(DayMenu day) { var complexes = _daydishrepo.ComplexDay(day.Date, this.User.GetHotelID()); //return View(_daydishrepo.DishesPerDay(daydate).ToList()); return(await Task.FromResult((IViewComponentResult)View("Default", complexes))); }
public void AddDistToOrderAsync(DayMenu dayMenu, Dish dish) { DateTime date = dayMenu.Date; Order order = OrderList.Find(o => o.Date == date); if (order == null) { int maxId; if (OrderList.Count == 0) { maxId = 0; } else { maxId = OrderList.Max(order => order.Id); } order = new Order { Id = maxId + 1, Date = date, UserId = "demo_user", Total = dish.Price, EatingAreaId = 0, Dishes = new List <Dish>() }; order.Dishes.Add(dish); OrderList.Add(order); } else { order.Dishes.Add(dish); order.Total += dish.Price; } }
/// <summary> /// Получить текущий список меню и заказов /// </summary> /// <returns>Подневный список пар менюБ заказ.</returns> public List <MenuOrder> GetMenuOrderListAsync() { var result = new List <MenuOrder>(); DayMenu dayMenu; foreach (var item in DayMenuList) { dayMenu = new DayMenu(item); var dishIdList = from record in DayMenuDetailsList where record.DayMenuId == dayMenu.Id select(record.DishId); dayMenu.Dishes = new List <Dish>(); foreach (var dishId in dishIdList) { var dishDTO = from d in DishList where d.Id == dishId select d; Dish dish = dishDTO.FirstOrDefault(); dish.Type = DishTypeList[dish.TypeId]; dayMenu.Dishes.Add(dish); } result.Add(new MenuOrder { DMenu = dayMenu, DOrder = null }); } return(result); }
public async Task <IViewComponentResult> InvokeAsync(DayMenu dayMenu) { // daydate = DateTime.Now; //return View(_daydishrepo.DishesPerDay(daydate).ToList()); return(await Task.FromResult((IViewComponentResult)View("Default", _daydishrepo.CategorizedDishesPerDay(dayMenu.Date, this.User.GetCompanyID())))); }
public async Task <IViewComponentResult> InvokeAsync(DayMenu day) { // daydate = DateTime.Now; //var cid = this.User.GetCompanyID(); //return View(_daydishrepo.DishesPerDay(daydate).ToList()); DateTime daydate = day.Date; ViewData["AllowEdit"] = _udaydishrepo.IsAllowDayEdit(daydate, this.User.GetHotelID()) && _udaydishrepo.GetConfrimedAdmin(this.User.GetUserId()) /*&& _udaydishrepo.IsBalancePositive(this.User.GetUserId())*/; ViewData["AllowAdmin"] = _udaydishrepo.GetConfrimedAdmin(this.User.GetUserId()); //to do check balance // ViewData["PositiveBalance"] = _udaydishrepo.IsBalancePositive(this.User.GetUserId()); if ((_udaydishrepo.GetCompanyOrderType(this.User.GetHotelID()) & OrderTypeEnum.OneComplexType) > 0) { var complexes = _udaydishrepo.AvaibleComplexDay(daydate, this.User.GetUserId(), this.User.GetHotelID()); complexes = complexes.OrderBy(com => com.ComplexCategoryCode); return(await Task.FromResult((IViewComponentResult)View("OneDayComplex", complexes))); } else { var complexes = _udaydishrepo.AvaibleComplexDayForMany(daydate, this.User.GetUserId(), this.User.GetHotelID()); complexes = complexes.OrderBy(com => com.ComplexCategoryCode); return(await Task.FromResult((IViewComponentResult)View("Default", complexes))); //return await Task.FromResult((IViewComponentResult)View("Default", _udaydishrepo.ComplexPerDay(daydate, this.User.GetUserId(), this.User.GetCompanyID()))); } // return await Task.FromResult((IViewComponentResult)View("Default", _udaydishrepo.AvaibleComplexDay(daydate, this.User.GetUserId(), this.User.GetCompanyID()))); }
public async Task <IViewComponentResult> InvokeAsync(DayMenu day) { var dayDishes = _daydishrepo.EnabledDishesPerDay(day.Date, this.User.GetHotelID()); return(await Task.FromResult((IViewComponentResult)View("CustomDishPerCategories", dayDishes))); //return await Task.FromResult((IViewComponentResult)View("Default", _daydishrepo.CategorizedDishesPerDay(day.Date,this.User.GetCompanyID()))); }
public async Task <IViewComponentResult> InvokeAsync(DayMenu day) { var complexes = _daydishrepo.ComplexDay(day.Date, this.User.GetCompanyID()); if (day.DishKind != 0) { complexes = complexes.Where(com => com.DishKindId == day.DishKind); } //return View(_daydishrepo.DishesPerDay(daydate).ToList()); return(await Task.FromResult((IViewComponentResult)View("Default", complexes))); }
public DayMenuViewModel(DayMenuPage page, DayMenu dayMenu) { _page = page; DayMenu = dayMenu; var dList = DayMenu.Dishes; var sorted = from item in dList orderby item.TypeId group item by item.Type.Plurals into itemGroup select new Grouping <string, Dish>(itemGroup.Key, itemGroup); ItemsGrouped = new ObservableCollection <Grouping <string, Dish> >(sorted); }
public IActionResult EditDayContent(DateTime daydate, int dishKind) { var dayMenu = new DayMenu() { Date = daydate, DishKind = dishKind, ShowComplex = (_dayDishesRepo.GetCompanyOrderType(this.User.GetCompanyID()) & (OrderTypeEnum.OneComplexType | OrderTypeEnum.Complex)) > 0, //ShowComplex = user.MenuType.HasValue && (user.MenuType.Value & 1) > 0, ShowDishes = (_dayDishesRepo.GetCompanyOrderType(this.User.GetCompanyID()) & OrderTypeEnum.Dishes) > 0 }; return(PartialView(dayMenu)); }
public IActionResult EditDayContent(DateTime daydate, int dishKind, OrderTypeEnum menuType) { //Company comp = _context.Companies.Find(User.GetCompanyID()); //if (comp == null) // return View("Error"); //OrderTypeEnum orderTypes = comp.GetOrderType(); var dayMenu = new DayMenu() { Date = daydate, MenuType = menuType }; return(PartialView(dayMenu)); }
public async Task <IViewComponentResult> InvokeAsync(DayMenu day) { // daydate = DateTime.Now; //var cid = this.User.GetCompanyID(); //return View(_daydishrepo.DishesPerDay(daydate).ToList()); DateTime daydate = day.Date; ViewData["AllowEdit"] = _udaydishrepo.IsAllowDayEdit(daydate, this.User.GetCompanyID()) && _udaydishrepo.GetConfrimedAdmin(this.User.GetUserId()) /*&& _udaydishrepo.IsBalancePositive(this.User.GetUserId())*/; ViewData["AllowAdmin"] = _udaydishrepo.GetConfrimedAdmin(this.User.GetUserId()); //to do check balance //ViewData["PositiveBalance"] = _udaydishrepo.IsBalancePositive(this.User.GetUserId()); IQueryable <UserDayComplexViewModel> complexes; string viewName = "Default"; if ((_udaydishrepo.GetCompanyOrderType(this.User.GetCompanyID()) & OrderTypeEnum.OneComplexType) > 0) { complexes = _udaydishrepo.AvaibleComplexDay(daydate, this.User.GetUserId(), this.User.GetCompanyID()); viewName = "OneDayComplex"; } else { complexes = _udaydishrepo.AllComplexDay(daydate, this.User.GetUserId(), this.User.GetCompanyID()); } if (day.DishKind != 0) { complexes = complexes.Where(com => com.DishKindId == day.DishKind); } if (day.Category != 0) { complexes = complexes.Where(com => com.ComplexCategoryId == day.Category); } if (day.Categories != null && day.Categories.Count > 0) { complexes = complexes.Where(com => day.Categories.Contains(com.ComplexCategoryId)); } complexes = complexes.OrderBy(com => com.ComplexCategoryCode); return(await Task.FromResult((IViewComponentResult)View(viewName, complexes))); //return await Task.FromResult((IViewComponentResult)View("Default", _udaydishrepo.ComplexPerDay(daydate, this.User.GetUserId(), this.User.GetCompanyID()))); // return await Task.FromResult((IViewComponentResult)View("Default", _udaydishrepo.AvaibleComplexDay(daydate, this.User.GetUserId(), this.User.GetCompanyID()))); }
/// <summary> /// Получить следующий список меню и заказов /// (на следующую неделю) /// </summary> /// <returns>Подневный список пар менюБ заказ.</returns> public async Task <List <MenuOrder> > GetMenuOrderListNextAsync() { Thread.Sleep(1000); // Для демо режима var result = new List <MenuOrder>(); DayMenu dayMenu; Order dayOrder; DateTime date; foreach (var item in DayMenuList) { dayMenu = new DayMenu(item); date = dayMenu.Date.Date; var dishIdList = from record in DayMenuDetailsList where record.DayMenuId == dayMenu.Id select(record.DishId); dayMenu.Dishes = new List <Dish>(); foreach (var dishId in dishIdList) { var dishDTO = from d in DishList where d.Id == dishId select d; Dish dish = dishDTO.FirstOrDefault(); dish.Type = DishTypeList[dish.TypeId]; dayMenu.Dishes.Add(dish); } dayOrder = OrderList.Find(o => o.Date.Date == date.Date); result.Add(new MenuOrder { DMenu = dayMenu, DOrder = dayOrder }); } return(result); }
//public DayMenuPage() //{ // InitializeComponent(); //} public DayMenuPage(DayMenu dayMenu = null) { InitializeComponent(); BindingContext = new DayMenuViewModel(this, dayMenu); }
/// <summary> /// Получить текущий список меню и заказов /// (на теущую неделю) /// </summary> /// <returns>Подневный список пар менюБ заказ.</returns> public async Task <List <MenuOrder> > GetMenuOrderListCurrentAsync() { var result = new List <MenuOrder>(); DayMenu dayMenu; Order dayOrder; DateTime date; int maxId; foreach (var item in DayMenuList) { dayMenu = new DayMenu(item); date = dayMenu.Date.Date; var dishIdList = from record in DayMenuDetailsList where record.DayMenuId == dayMenu.Id select(record.DishId); dayMenu.Dishes = new List <Dish>(); foreach (var dishId in dishIdList) { var dishDTO = from d in DishList where d.Id == dishId select d; Dish dish = dishDTO.FirstOrDefault(); dish.Type = DishTypeList[dish.TypeId]; dayMenu.Dishes.Add(dish); } dayOrder = OrderList.Find(o => o.Date.Date == date.Date); if (dayOrder == null) { if (OrderList == null || OrderList.Count == 0) { maxId = 0; } else { maxId = OrderList.Max(order => order.Id); } dayOrder = new Order { // OrderDTO Id = maxId !+1, Date = date, UserId = "demo user", Total = 0L, EatingAreaId = 0, OrderStatusId = 0, // Order UserName = "******", EatingArea = null, Status = OrderStatus.NotDefined, Dishes = null }; OrderList.Add(dayOrder); } result.Add(new MenuOrder { DMenu = dayMenu, DOrder = dayOrder }); } return(result); }
public ActionResult AddDiaMenu(int id) { var dias = new List <Dias>(); var menudia = db.DayMenu.Where(md => md.Cod_Menu == id).ToList(); if (menudia != null) { foreach (var item in menudia) { var dia = new Dias { Cod_Dia = item.Cod_Dia, Nombre_Dia = item.Dias.Nombre_Dia }; dias.Add(dia); } } else { ModelState.AddModelError(string.Empty, "No tiene Dias Asignados"); ViewBag.Error = true; } var ListDia = db.Dias.ToList(); var menu = db.Menus.Find(id); var diaMenuView = new DiaMenuView(); int diaid = Convert.ToInt32(Request["DiasId"]); if (diaid == 0) { ModelState.AddModelError(string.Empty, "Por favor seleccione el dia"); ViewBag.Error = true; } var daymenu = db.DayMenu.Where(dm => dm.Cod_Menu == id && dm.Cod_Dia == diaid).ToList(); if (daymenu.Count() != 0) { diaMenuView.Menu = menu; diaMenuView.Dia = new Dias(); diaMenuView.Dias = dias.OrderBy(d => d.Cod_Dia).ToList(); ModelState.AddModelError(string.Empty, "Ya se añadido ese dia"); ViewBag.Error = true; ListDia.Add(new Dias { Cod_Dia = 0, Nombre_Dia = "{Seleccione el Dia...}" }); ViewBag.DiasId = new SelectList(ListDia.OrderBy(d => d.Cod_Dia).ToList(), "Cod_Dia", "Nombre_Dia"); return(View(diaMenuView)); } var diamenu = new DayMenu { Cod_Dia = Convert.ToInt32(diaid), Cod_Menu = id }; try { db.DayMenu.Add(diamenu); db.SaveChanges(); } catch (Exception ex) { ModelState.AddModelError(string.Empty, ex.Message); ViewBag.Error = true; } if (diaid != 0) { var Ndia = db.Dias.Find(Convert.ToInt32(diaid)); var dia1 = new Dias { Cod_Dia = Ndia.Cod_Dia, Nombre_Dia = Ndia.Nombre_Dia }; dias.Add(dia1); } diaMenuView.Menu = menu; diaMenuView.Dia = new Dias(); diaMenuView.Dias = dias.OrderBy(d => d.Cod_Dia).ToList(); ListDia.Add(new Dias { Cod_Dia = 0, Nombre_Dia = "Seleccione el Dia" }); ViewBag.DiasId = new SelectList(ListDia.OrderBy(d => d.Cod_Dia).ToList(), "Cod_Dia", "Nombre_Dia"); return(View(diaMenuView)); }