public async Task <IActionResult> Create(BrewsViewModel brew) { if (brew == null) { NotFound(); } string name = brew.Name; brew.IsNew = true; brew.IsValid = false; if (!ModelState.IsValid) { return(View(brew)); } if (!ValidateBrew(brew) || !await brewService.FindIfNameIsUniqueAsync(name)) { return(View(brew)); } else { BrewModel newBrew = mapper.BrewsViewModelToBrew(brew); newBrew.Recipes = brew.Recipes; brewService.AddBrewAndRecipesAsync(newBrew); brew.IsValid = true; return(RedirectToAction(RoutingConstants.BrewsManagementIndex)); } }