public ActionResult Create(Exit_Permission_Reason model)
 {
     try
     {
         dbcontext.Exit_Permission_Reason.Add(model);
         dbcontext.SaveChanges();
         return(RedirectToAction("index"));
     }
     catch (Exception)
     {
         return(View(model));
     }
 }
 public ActionResult Edit(Exit_Permission_Reason model)
 {
     try
     {
         var record = dbcontext.Exit_Permission_Reason.FirstOrDefault(m => m.ID == model.ID);
         record.Name        = model.Name;
         record.Description = model.Description;
         dbcontext.SaveChanges();
         return(RedirectToAction("index"));
     }
     catch (Exception)
     {
         return(View(model));
     }
 }
 public ActionResult Create()
 {
     try
     {
         var record = new Exit_Permission_Reason();
         var stru   = dbcontext.StructureModels.FirstOrDefault(m => m.All_Models == ChModels.Personnel).Structure_Code;
         var model  = dbcontext.Exit_Permission_Reason.ToList();
         if (model.Count() == 0)
         {
             record.Code = stru + "1";
         }
         else
         {
             record.Code = stru + (model.LastOrDefault().ID + 1).ToString();
         }
         return(View(record));
     }
     catch (Exception)
     {
         return(RedirectToAction("index"));
     }
 }