Exemple #1
0
        public ActionResult Category(int?id, string E)
        {
            if (id > 0 && E == "D")
            {
                CM_Categories model = db.CM_Categories.Find(id);
                db.Entry(model).State = EntityState.Deleted;
                db.SaveChanges();
                TempData["msg"] = "Deleted Sucessfully!";
                return(RedirectToAction("CategoryDetails"));
            }

            else if (id > 0)
            {
                CM_Categories model = db.CM_Categories.Find(id);
                return(View(model));
            }
            return(View());
        }
Exemple #2
0
 public ActionResult Category(CM_Categories model, int?id)
 {
     if (ModelState.IsValid)
     {
         if (id > 0)
         {
             db.Entry(model).State = EntityState.Modified;
             db.SaveChanges();
             ModelState.Clear();
             TempData["msg"] = "Update Succussfully";
         }
         else
         {
             db.CM_Categories.Add(model);
             db.SaveChanges();
             ModelState.Clear();
             TempData["msg"] = "Category Created Successfully";
         }
     }
     return(RedirectToAction("CategoryDetails"));
 }