public ActionResult Create(string id) { ViewBag.Employee_Profile = dbcontext.Employee_Profile.ToList().Select(m => new { Code = m.Code + "------[" + m.Name + ']', ID = m.ID }); var stru = dbcontext.StructureModels.FirstOrDefault(m => m.All_Models == ChModels.Recuirtment); var model = dbcontext.Committe_Resolution_Recuirtment.ToList(); var count = 0; if (model.Count() == 0) { count = 1; } else { var te = model.LastOrDefault().ID; count = te + 1; } var Statis = DateTime.Now; var CommitteResolutionRecuirtment = new Committe_Resolution_Recuirtment { Code = stru.Structure_Code + count.ToString(), Committe_Resolution_Date = Statis, Committe_Year = DateTime.Today.Year }; return(View(CommitteResolutionRecuirtment)); }
public ActionResult Create(FormCollection form, Committe_Resolution_Recuirtment model, string Command) { try { ViewBag.Employee_Profile = dbcontext.Employee_Profile.ToList().Select(m => new { Code = m.Code + "------[" + m.Name + ']', ID = m.ID }); if (ModelState.IsValid) { var emp_profile = form["Employee_profile_No2"].Split(char.Parse(",")); var Emp_name = form["Employee_name"].Split(char.Parse(",")); var Head = form["Is_Head"].Split(char.Parse(",")); var items = new List <Append_Committe_Member>(); for (var i = 0; i < emp_profile.Count(); i++) { if (emp_profile[i] != "" && Emp_name[i] != "" && Head[i] != "") { items.Add(new Append_Committe_Member { Is_Committe_Head = Head[i], Employee_profile = emp_profile[i], Employee_Name = Emp_name[i] }); } } if (items.Count() > 0) { var add_items = dbcontext.Append_Committe_Member.AddRange(items); dbcontext.SaveChanges(); ///////////////////////////////////// var username = User.Identity.GetUserName(); var Date = Convert.ToDateTime("1/1/1900"); var s = new status { statu = check_status.created, created_by = username, Type = Models.Infra.Type.Committe_Resolution_Recuirtment, approved_bydate = Date, cancaled_bydate = Date, created_bydate = DateTime.Now.Date, Rejected_bydate = Date, return_to_reviewdate = Date }; var st = dbcontext.status.Add(s); dbcontext.SaveChanges(); /////////////////////////////// var benfit = new Committe_Resolution_Recuirtment { check_status = check_status.created, statID = s.ID, Append_Committe_Member = add_items.ToList(), Code = model.Code, Committe_Usage = model.Committe_Usage, Committe_Location = model.Committe_Location, Committe_Resolution_Date = model.Committe_Resolution_Date, Committe_Year = model.Committe_Year, Committe_Resolution_Status = model.Committe_Resolution_Status, Committe_Type = model.Committe_Type, Committe_Conclusion = model.Committe_Conclusion }; var record = dbcontext.Committe_Resolution_Recuirtment.Add(benfit); dbcontext.SaveChanges(); //if (Command == "Submit5" && record.Committe_Usage == Committe_Usage.Personnel) //{ // TempData["Message"] = HR.Resource.Personnel.YoumustchooseTestFromCommitteUsage; // return View(model); //} //if ((Command == "Submit" && record.Committe_Usage == Committe_Usage.Test) || (Command == "Submit2" && record.Committe_Usage == Committe_Usage.Test) || (Command == "Submit3" && record.Committe_Usage == Committe_Usage.Test) || (Command == "Submit4" && record.Committe_Usage == Committe_Usage.Test)) //{ // TempData["Message"] = HR.Resource.Personnel.YoumustchoosePersonnelFromCommitteUsage; // return View(model); //} if (Command == "Submit" && record.Committe_Usage == Committe_Usage.Personnel) { return(RedirectToAction("Create", "Commitee_Agenda", new { id = record.ID })); } if (Command == "Submit2" && record.Committe_Usage == Committe_Usage.Personnel) { return(RedirectToAction("Create", "Out_Organization", new { id = record.ID })); } if (Command == "Submit3" && record.Committe_Usage == Committe_Usage.Personnel) { return(RedirectToAction("Create", "In_Organization", new { id = record.ID })); } if (Command == "Submit4" && record.Committe_Usage == Committe_Usage.Personnel) { return(RedirectToAction("Create", "Committe_Activities", new { id = record.ID })); } if (Command == "Submit5" && record.Committe_Usage == Committe_Usage.Test) { return(RedirectToAction("Create", "Linked_to_Testing", new { id = record.ID })); } } dbcontext.SaveChanges(); return(RedirectToAction("Index")); } else { return(View(model)); } } catch (DbUpdateException e) { TempData["Message"] = HR.Resource.Basic.thiscodeIsalreadyexists; return(View(model)); } catch (Exception e) { return(View(model)); } }