// GET: Console/MenuManagement public ActionResult MenuManagement(string date) { var model = new ConsoleModels.MenuManagementDto(); var list = Entities.Menu.Cache.MenuListActive; if (!string.IsNullOrEmpty(date) && DateTime.TryParse(date, out var menuDate)) { list = list.FindAll(x => x.MenuDate == menuDate); model.MenuDate = menuDate; } if (list != null && list.Count > 0) { var mapper = MenuDto.ConfigMapper().CreateMapper(); model.Menus = mapper.Map <IEnumerable <MenuDto> >(list.AsEnumerable()).ToList(); } return(View(model)); }
// GET: Reservation public ActionResult Index() { var model = new ReservationModels.IndexDto(); var menuType = MenuDto.GetMenuLunchOrSupper(); var menuA = Menu.Cache.MenuListActiveToday.Find(x => x.MenuType == menuType && x.MenuFlag == "A"); var menuB = Menu.Cache.MenuListActiveToday.Find(x => x.MenuType == menuType && x.MenuFlag == "B"); var mapper = MenuDto.ConfigMapper().CreateMapper(); if (menuA != null) { model.MenuA = mapper.Map <MenuDto>(menuA); } if (menuB != null) { model.MenuB = mapper.Map <MenuDto>(menuB); } // 可以订餐,无相关订餐历史记录 if (menuA != null && menuB != null && CanReserveNow(new[] { menuA.ID, menuB.ID })) { model.MenuDate = DateTime.Today; model.DeliveryZones = Delivery.Cache.DeliveryZoneList; // 设置当前用户的默认送餐区域,先判断用户的职务,再判断用户的班组 if (_authorizedUser != null) { var rela = _repo.Single <RelationTeamPositionDelivery>(x => x.Position == _authorizedUser.Position) ?? _repo.Single <RelationTeamPositionDelivery>(x => x.Team == _authorizedUser.Team); if (rela != null) { model.MyDefaultDeliveryZone = Delivery.Cache.Load(rela.DeliveryGuid); } } if (menuType.Equals(MenuTypeEnum.Lunch)) { model.MenuStyle = "green"; } else if (menuType.Equals(MenuTypeEnum.Supper)) { model.MenuStyle = "purple"; } model.CanReserveNow = true; } else { model.CanReserveNow = false; } // 获取今天最新订餐记录 if (menuA != null && menuB != null) { model.MyCurrentOrder = GetMyCurrentOrder(new[] { menuA.ID, menuB.ID }); } return(View(model)); }