Exemplo n.º 1
0
        //Create
        public bool Create(IngredientViewCreateModel model)
        {
            var ingredient = new Ingredient
            {
                UserId = model.UserId,
                Name   = model.Name
            };

            ingredient = ingredientRepo.Create(ingredient);
            return(ingredient.Id != 0);
        }
Exemplo n.º 2
0
        public ActionResult Create(IngredientViewCreateModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            model.UserId = Guid.Parse(User.Identity.GetUserId());

            if (IngredientService.Create(model))
            {
                TempData["SaveResult"] = "Your ingredient was created.";
                return(RedirectToAction("Index"));
            }
            ;
            ModelState.AddModelError("", "Ingredient could not be created.");
            return(View(model));
        }
Exemplo n.º 3
0
        //GET
        public ActionResult Create()
        {
            IngredientViewCreateModel model = new IngredientViewCreateModel();

            return(View(model));
        }