public IActionResult Search(SearchMealInputModel inputModel, int id = 1) { if (id <= 0) { return(this.NotFound()); } const int ItemsPerPage = 15; var result = this.mealService.GetAllSearched <MealInListViewModel>(inputModel, id); if (result.Count == 0) { return(this.NotFound()); } var viewModel = new MealListViewModel { PageNumber = id, TotalCount = result.Count, Meals = result.Meals, ItemsPerPage = ItemsPerPage, Name = inputModel.Name, CategoryId = inputModel.CategoryId, SubCategory = inputModel.SubCategory, SkillLevel = inputModel.SkillLevel, PortionCount = inputModel.PortionCount, PreparationTime = inputModel.PreparationTime, CookingTime = inputModel.CookingTime, }; return(this.View(viewModel)); }
public ViewResult MealList() { EFDBContext context = new EFDBContext(); MealListViewModel model = new MealListViewModel { Meals = context.Meals .OrderBy(m => m.mealID) }; return(View(model)); }
public IActionResult All(int id = 1) { if (id <= 0) { return(this.NotFound()); } const int ItemsPerPage = 15; var viewModel = new MealListViewModel { PageNumber = id, TotalCount = this.mealService.GetAllMealsCount(), Meals = this.mealService.GetAll <MealInListViewModel>(id), ItemsPerPage = ItemsPerPage, }; return(this.View(viewModel)); }
public async Task <ActionResult> Index(DateTime?t) { var date = t ?? Clock.Now; var meals = (await _mealService.GetAll(new PagedAndSortedResultRequestDto { MaxResultCount = int.MaxValue })).Items; var dayMeals = meals.Where(m => m.Date.Date == date.Date).ToList(); var ingredients = (await _ingredientService.GetAll(new PagedAndSortedResultRequestDto { MaxResultCount = int.MaxValue })).Items; //var users = (await _userAppService.GetAll(new PagedResultRequestDto { MaxResultCount = int.MaxValue })).Items; //Paging not implemented yet //var roles = (await _userAppService.GetRoles()).Items; var vm = new MealListViewModel() { Meals = dayMeals, Day = date, Ingredients = ingredients }; //var meals = db.Meals.Include(m => m.User); return(View(vm)); }
public MealList() { InitializeComponent(); BindingContext = new MealListViewModel(); }