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 New(Dish NewDish) { if (ModelState.IsValid) { dbContext.Dishes.Add(NewDish); dbContext.SaveChanges(); return(RedirectToAction("Index")); } else { return(View()); } }
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")); } }
private void AddOrder(Dish dish) { _context.OrderedDish.Add(new OrderedDish() { DishId = dish.Id }); _context.SaveChanges(); }
public IActionResult Create(Dish dish) { if (ModelState.IsValid) { if (dbContext.Dishes.Any(d => d.Name == dish.Name && d.Chef == dish.Chef)) { ModelState.AddModelError("Dish", $"{dish.Chef}'s {dish.Name} is already in the system"); ViewBag.Dishes = dbContext.Dishes.Reverse().Take(10); return(View("New")); } dbContext.Dishes.Add(dish); dbContext.SaveChanges(); return(RedirectToAction("Index")); } return(View("New")); }
public OrderPageAllDishController(DishContext context) { _context = context; if (_context.Dish.Count() == 0) { _context.Dish.Add(new Dish { IsComplete = false, Name = "SchabowySpokoLux", Desc = "Calkiem spoko" }); _context.SaveChanges(); } }
public IActionResult Create(Dish newDish) { if (ModelState.IsValid) { dbContext.Add(newDish); dbContext.SaveChanges(); return(Redirect("/")); } else { return(View("NewDish")); } }
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 void Save() { db.SaveChanges(); }
public IActionResult AddDish(Dish NewDish) { dbContext.Add(NewDish); dbContext.SaveChanges(); return(RedirectToAction("Index")); }