Ejemplo n.º 1
0
 public ActionResult Create(STRG_LOC_TBL storageModel, FormCollection collection)
 {
     try
     {
         using (DMSDbEntities db = new DMSDbEntities())
         {
             db.STRG_LOC_TBL.Add(storageModel);
             db.SaveChanges();
             return RedirectToAction("Index", db.STRG_LOC_TBL.ToList());
         }
     }
     catch
     {
         return View();
     }
 }
Ejemplo n.º 2
0
        public ActionResult Edit(int id,STRG_LOC_TBL storageModel, FormCollection collection)
        {
            try
            {
                using (DMSDbEntities db = new DMSDbEntities())
                {
                    storageModel.STRG_ID = id;
                    var entry = db.Entry<STRG_LOC_TBL>(storageModel);
                    if (entry.State.Equals(EntityState.Detached))
                    {
                        db.STRG_LOC_TBL.Attach(storageModel);
                    }
                    entry.State = EntityState.Modified;
                    db.SaveChanges();
                    return RedirectToAction("Index", db.STRG_LOC_TBL.ToList());
                }


            }
            catch
            {
                return View();
            }
        }
Ejemplo n.º 3
0
 public ActionResult Delete(int id, STRG_LOC_TBL storageModel, FormCollection collection)
 {
     try
     {
         using (DMSDbEntities db = new DMSDbEntities())
         {
             storageModel = db.STRG_LOC_TBL.FirstOrDefault(p => p.STRG_ID == id);
             var entry = db.Entry<STRG_LOC_TBL>(storageModel);
             entry.State = EntityState.Deleted;
             db.STRG_LOC_TBL.ToList().RemoveAll(p => p.STRG_ID == storageModel.STRG_ID);
             db.SaveChanges();
             return RedirectToAction("Index", db.STRG_LOC_TBL.ToList());
         }
     }
     catch
     {
         return View();
     }
 }