예제 #1
0
 public ActionResult Edit([Bind(Include = "Id,PracticeSpecialityType,IsActive,CreatedOn,CreatedBy,UpdatedOn,UpdatedBy")] LookupPracticeSpecialityType lookupPracticeSpecialityType)
 {
     if (ModelState.IsValid)
     {
         lookupPracticeSpecialityType.UpdatedBy       = CurrentUser.Id;
         lookupPracticeSpecialityType.UpdatedOn       = DateTime.UtcNow;
         db.Entry(lookupPracticeSpecialityType).State = EntityState.Modified;
         db.SaveChanges();
         lookupPracticeSpecialityType.ClearCache(CacheKeys.PracticeSpecialities);
         return(RedirectToAction("Index"));
     }
     ViewBag.CreatedBy = new SelectList(db.Users, "Id", "UserName", lookupPracticeSpecialityType.CreatedBy);
     ViewBag.UpdatedBy = new SelectList(db.Users, "Id", "UserName", lookupPracticeSpecialityType.UpdatedBy);
     return(View(lookupPracticeSpecialityType));
 }
예제 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            LookupPracticeSpecialityType lookupPracticeSpecialityType = db.LookupPracticeSpecialityTypes.Find(id);

            try
            {
                db.LookupPracticeSpecialityTypes.Remove(lookupPracticeSpecialityType);
                db.SaveChanges();
                lookupPracticeSpecialityType.ClearCache(CacheKeys.PracticeSpecialities);
            }
            catch (DbUpdateException ex)
            {
                ModelState.AddModelError("Error", "There are some releted item in database, please delete those first");
                return(View("Delete", lookupPracticeSpecialityType));
            }
            return(RedirectToAction("Index"));
        }