Ejemplo n.º 1
0
 public BrewViewModel(BrewDomModel model)
 {
     this.Id          = model.Id.ToString();
     this.Name        = model.Name;
     this.Description = model.Description;
     this.RecipeName  = model.RecipeName;
 }
Ejemplo n.º 2
0
        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));
            }
        }
Ejemplo n.º 3
0
 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;
 }
Ejemplo n.º 4
0
        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)));
            }
        }