public ActionResult Create(Committe_subjects model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    Committe_subjects record = new Committe_subjects();
                    record.Name        = model.Name;
                    record.Description = model.Description;
                    record.Code        = model.Code;
                    dbcontext.Committe_subjects.Add(record);
                    dbcontext.SaveChanges();

                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(View(model));
                }
            }
            catch (DbUpdateException)
            {
                TempData["Message"] = "this code Is already exists";
                return(View(model));
            }
            catch (Exception e)
            {
                return(View(model));
            }
        }
        public ActionResult Create()
        {
            var modell = new Committe_subjects();

            var stru  = dbcontext.StructureModels.FirstOrDefault(m => m.All_Models == ChModels.Recuirtment).Structure_Code;
            var model = dbcontext.Committe_subjects.ToList();

            if (model.Count() == 0)
            {
                modell.Code = stru + "1";
            }
            else
            {
                modell.Code = stru + (model.LastOrDefault().ID + 1).ToString();
            }
            return(View(modell));
        }
 public ActionResult Edit(Committe_subjects model)
 {
     try
     {
         var record = dbcontext.Committe_subjects.FirstOrDefault(m => m.ID == model.ID);
         record.Name        = model.Name;
         record.Description = model.Description;
         record.Code        = model.Code;
         dbcontext.SaveChanges();
         return(RedirectToAction("index"));
     }
     catch (DbUpdateException)
     {
         TempData["Message"] = "this code Is already exists";
         return(View(model));
     }
     catch (Exception e)
     { return(View(model)); }
 }