public BrewViewModel(BrewDomModel model) { this.Id = model.Id.ToString(); this.Name = model.Name; this.Description = model.Description; this.RecipeName = model.RecipeName; }
public ActionResult Edit(BrewBindingModel model, string id) { if (!ModelState.IsValid) { return(RedirectToAction("Edit", "Brew", id)); } try { BrewDomModel toEdit = new BrewDomModel { Id = Guid.Parse(id), Name = model.Name, Description = model.Description, RecipeId = Guid.Parse(model.RecipeId) }; this.manager.Edit(toEdit); return(RedirectToAction(nameof(Index))); } catch { return(RedirectToAction("Edit", "Edit", id)); } }
public BrewBindingModel(BrewDomModel domObj, SelectList recipes) { this.Name = domObj.Name; this.Description = domObj.Description; this.RecipeId = domObj.RecipeId.ToString(); this.RecipeName = domObj.RecipeName; this.Recipes = recipes; }
public ActionResult Create(BrewBindingModel model) { if (!ModelState.IsValid) { return(RedirectToAction(nameof(Create))); } try { var brew = new BrewDomModel { Name = model.Name, Description = model.Description, RecipeId = Guid.Parse(model.RecipeId), }; this.manager.Add(brew); return(RedirectToAction(nameof(Index))); } catch { return(RedirectToAction(nameof(Create))); } }