Ejemplo n.º 1
0
        public ActionResult Create(CTGRY_TBL categoryModel)
        {
            try
            {
                using (DMSDbEntities db = new DMSDbEntities())
                {
                    db.CTGRY_TBL.Add(categoryModel);
                    db.SaveChanges();


                    return RedirectToAction("Index",db.CTGRY_TBL.ToList());
                }
            }
            catch
            {
                return View();
            }
        }
Ejemplo n.º 2
0
        public ActionResult Edit(CTGRY_TBL categoryModel)
        {
            try
            {
                using (DMSDbEntities db = new DMSDbEntities())
                {
                    var entry = db.Entry<CTGRY_TBL>(categoryModel);
                    if (entry.State.Equals(EntityState.Detached))
                    {
                        db.CTGRY_TBL.Attach(categoryModel);
                    }
                    entry.State = EntityState.Modified;
                    db.SaveChanges();


                    return RedirectToAction("Index",db.CTGRY_TBL.ToList());
                }
            }
            catch
            {
                return View();
            }
        }
Ejemplo n.º 3
0
 public ActionResult Delete(CTGRY_TBL categoryModel)
 {
     try
     {
         using (DMSDbEntities db = new DMSDbEntities())
         {
             var entry = db.Entry<CTGRY_TBL>(categoryModel);
             entry.State = EntityState.Deleted;
             db.CTGRY_TBL.ToList().RemoveAll(p => p.CtgryId == categoryModel.CtgryId);
             db.SaveChanges();
             return RedirectToAction("Index", db.CTGRY_TBL.ToList());
         }
     }
     catch
     {
         return View();
     }
 }