public async Task <IActionResult> Add() { var model = new AddDessertInputModel() { Categories = await this.categoriesService.GetAllAsSelectListItemAsync(), }; return(this.View(model)); }
public async Task <IActionResult> Add(AddDessertInputModel input) { if (!this.ModelState.IsValid) { input.Categories = await this.categoriesService.GetAllAsSelectListItemAsync(); return(this.View(input)); } await this.dessertsService.AddAsync(input.Name, input.Picture, input.Price, input.Description, input.CategoryId); this.TempData["InfoMessage"] = GlobalConstants.SuccessAddedMessage; return(this.RedirectToAction(nameof(this.GetAll))); }