public IActionResult Index() { ViewBag.CurrentWeek = mealRepository.CurrentWeekMeals(); ViewBag.NextWeek = mealRepository.NextWeekMeals(); DateTime startOfWeek = DateTime.Today.AddDays(-(int)DateTime.Today.DayOfWeek + (int)DayOfWeek.Monday).AddDays(-7); var user = userRepository.GetUserByEmail(User.Identity.Name); var orders = orderRepository.GetOrdersByUserId(user.UserId); var ordersForThisWeek = orders.Where(x => x.Date > startOfWeek); WeekOrder wo = weekOrderRepository .GetWeekOrdersByCustomerId(user.UserId) .Where(x => x.StartDate == startOfWeek.Date) .FirstOrDefault(); ViewBag.TotalPrice = 0; if (wo != null) { ViewBag.TotalPrice = wo.TotalPrice; } DaysLeftToOrder(ordersForThisWeek); return(View()); }
public IQueryable <MealResult> GetMealsFromCurrentWeek() { return(mealRepository.CurrentWeekMeals()); }