public IActionResult Dishprocessor(Dish newdish) { if (ModelState.IsValid) { dbContext.Add(newdish); dbContext.SaveChanges(); return(RedirectToAction("Dishes")); } return(RedirectToAction("Adddish")); }
public IActionResult CreateDish(Dish newDish) { if (ModelState.IsValid) { dbContext.Add(newDish); dbContext.SaveChanges(); return(RedirectToAction("Index")); } return(View("New")); }
public IActionResult AddDish(Dish NewDish) { if (ModelState.IsValid) { dbContext.Add(NewDish); dbContext.SaveChanges(); return(RedirectToAction("index")); } else { return(View("NewForm")); } }
public IActionResult Create(Dish newDish) { if (ModelState.IsValid) { dbContext.Add(newDish); dbContext.SaveChanges(); return(Redirect("/")); } else { return(View("NewDish")); } }
public IActionResult CreateDish(Dish fromForm) { if (ModelState.IsValid) { _context.Add(fromForm); _context.SaveChanges(); return(RedirectToAction("Index")); } else { return(View("DishForm")); } }
public IActionResult AddDish(Dishes dish) { if (ModelState.IsValid) { dbContext.Add(dish); dbContext.SaveChanges(); return(RedirectToAction("index")); } else { // Oh no! We need to return a ViewResponse to preserve the ModelState, and the errors it now contains! return(View("Create")); } }
public IActionResult AddDish(Dish newDish) { if (ModelState.IsValid) { Console.WriteLine($"***********************{newDish.Chef} | {newDish.Name} | {newDish.Calories} | {newDish.Tastiness} | {newDish.Description}***********************"); dbContext.Add(newDish); dbContext.SaveChanges(); return(RedirectToAction("Index")); } else { return(View("new")); } }
public IActionResult AddDish(Dish dish) { if (ModelState.IsValid) { Dish newdish = dish; dbContext.Add(newdish); dbContext.SaveChanges(); return(RedirectToAction("Index")); } else { Console.WriteLine("NOT VALID**************", ModelState.Keys); foreach (var error in ModelState) { if (error.Value.Errors.Count > 0) { Console.WriteLine("err msg " + error.Value.Errors[0].ErrorMessage); } } return(RedirectToAction("Add")); } }
public IActionResult Create(DishViewModel dish) { if (!ModelState.IsValid) { return(View("New")); } Dish newDish = new Dish { DishName = dish.DishName, Chef = dish.Chef, Tastiness = dish.Tastiness, Calories = dish.Calories, Description = dish.Description, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now }; _context.Add(newDish); _context.SaveChanges(); Console.WriteLine("######################################################ADEDD##########################"); return(RedirectToAction("Index")); }
public IActionResult AddDish(Dish NewDish) { dbContext.Add(NewDish); dbContext.SaveChanges(); return(RedirectToAction("Index")); }