コード例 #1
0
        public async Task <IActionResult> Index()
        {
            var user = await _userManager.GetUserAsync(HttpContext.User);

            if (user == null)
            {
                return(NotFound());
            }
            UserDayEditModel model = new UserDayEditModel()
            {
                DayDate = DateTime.Now,
                //ShowComplex = user.MenuType.HasValue && (user.MenuType.Value & 1) > 0,
                //ShowDishes = user.MenuType.HasValue && (user.MenuType.Value & 2) > 0,
                ShowComplex = (_userdaydishesrepo.GetCompanyOrderType(this.User.GetCompanyID()) & (OrderTypeEnum.OneComplexType | OrderTypeEnum.Complex)) > 0,
                ShowDishes  = (_userdaydishesrepo.GetCompanyOrderType(this.User.GetCompanyID()) & OrderTypeEnum.Dishes) > 0
            };
            DateTime daydate = DateTime.Now;

            //daydate = daydate.AddDays(1);
            if (daydate.DayOfWeek == DayOfWeek.Saturday || daydate.DayOfWeek == DayOfWeek.Sunday)
            {
                daydate = daydate.AddDays(2);
            }
            DateTime startDate = daydate.StartOfWeek(DayOfWeek.Monday);
            DateTime endDate   = startDate.AddDays(6);
            var      list      = _userdaydishesrepo.DishesKind(startDate, endDate, User.GetCompanyID());

            ViewData["DishKindId"] = new SelectList(list, "Value", "Text", list.FirstOrDefault());
            return(View(model)); //await _userdishes.CategorizedDishesPerDay(DateTime.Now, _userManager.GetUserId(HttpContext.User)).ToListAsync());
        }