예제 #1
0
 public ActionResult Add(Restaurant objRestaurant)
 {
     if (string.IsNullOrEmpty(objRestaurant.Name))
     {
         ModelState.AddModelError("Name", "Please enter the Name");
     }
     if (ModelState.Values.SelectMany(s => s.Errors).Count() > 0)
     {
         return View(objRestaurant);
     }
     objRestaurant.CreatedDtm = DateTime.Now;
     objRestaurant.Status = 1;
     objContext.ContextRestaurant.Add(objRestaurant);
     objContext.SaveChanges();
     return RedirectToAction("List");
 }
예제 #2
0
 public ActionResult Edit(Restaurant objRestaurant)
 {
     if (string.IsNullOrEmpty(objRestaurant.Name))
     {
         ModelState.AddModelError("Name", "Please enter the Name");
     }
     if (ModelState.Values.SelectMany(s => s.Errors).Count() > 0)
     {
         return View(objRestaurant);
     }
     Restaurant objRestaurantExist = objContext.ContextRestaurant.SingleOrDefault(s => s.Id == objRestaurant.Id);
     if (objRestaurantExist != null)
     {
         objRestaurantExist.Name = objRestaurant.Name;
         objContext.SaveChanges();
     }
     return RedirectToAction("List");
 }