public ActionResult Create(Employee_Recodes_Group model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             Employee_Recodes_Group record = new Employee_Recodes_Group();
             record.Record_Group_Code        = model.Record_Group_Code;
             record.Record_Group_Description = model.Record_Group_Description;
             record.Record_Group_Alternative = model.Record_Group_Alternative;
             record.Linkedtopayroll          = model.Linkedtopayroll;
             record.Linkedtobasicpayment     = model.Linkedtobasicpayment;
             record.Linkedtoanotherpayment   = model.Linkedtoanotherpayment;
             dbcontext.Employee_Recodes_Group.Add(record);
             dbcontext.SaveChanges();
             return(RedirectToAction("Index"));
         }
         else
         {
             return(View(model));
         }
     }
     catch (DbUpdateException)
     {
         TempData["Message"] = HR.Resource.Basic.thiscodeIsalreadyexists;
         return(View(model));
     }
     catch (Exception e)
     {
         return(View(model));
     }
 }
        public ActionResult Create()
        {
            var stru  = dbcontext.StructureModels.FirstOrDefault(m => m.All_Models == ChModels.Personnel);
            var model = dbcontext.Employee_Recodes_Group.ToList();
            var count = 0;

            if (model.Count() == 0)
            {
                count = 1;
            }
            else
            {
                var te = model.LastOrDefault().ID;
                count = te + 1;
            }

            var modell = new Employee_Recodes_Group {
                Record_Group_Code = stru.Structure_Code + count
            };

            return(View(modell));
        }
 public ActionResult Edit(Employee_Recodes_Group model)
 {
     try
     {
         var record = dbcontext.Employee_Recodes_Group.FirstOrDefault(m => m.ID == model.ID);
         record.Record_Group_Code        = model.Record_Group_Code;
         record.Record_Group_Description = model.Record_Group_Description;
         record.Record_Group_Alternative = model.Record_Group_Alternative;
         record.Linkedtopayroll          = model.Linkedtopayroll;
         record.Linkedtobasicpayment     = model.Linkedtobasicpayment;
         record.Linkedtoanotherpayment   = model.Linkedtoanotherpayment;
         dbcontext.SaveChanges();
         return(RedirectToAction("index"));
     }
     catch (DbUpdateException)
     {
         TempData["Message"] = HR.Resource.Basic.thiscodeIsalreadyexists;
         return(View(model));
     }
     catch (Exception e)
     { return(View(model)); }
 }