public ActionResult AddEdit(int?id) { NewStaffJoiningViewModel model = new NewStaffJoiningViewModel(); model.GenderListItems = Genders(db.md_type.Where(x => x.type.Equals("Gender")).ToList()); model.HrDepartmentListItems = HrDepartments(db.hr_department.ToList()); model.ReligionListItems = Religions(db.md_type.Where(x => x.type.Equals("Religion")).ToList()); model.HrDesignationListItems = HrDesignations(); model.IsAirTicket = IsAirticket(); model.PassportCountryList = PassportCountry(db.md_type.Where(x => x.type.Equals("Country")).ToList()); if (id > 0) { model.NewStaffJoining = db.NewStaffJoinings.Where(x => x.Id == id).FirstOrDefault(); } return(View(model)); }
public ActionResult Post(NewStaffJoiningViewModel model) { model.NewStaffJoining.CertifiedOn = DateTime.Now; model.NewStaffJoining.CertifiedBy = User.Identity.Name == "" ? "Naveed" : User.Identity.Name; //int gndrid = Convert.ToInt32(model.NewStaffJoining.Gender); //model.NewStaffJoining.Gender = db.md_type.Where(x => x.Id == gndrid).FirstOrDefault().Name; //int countryid = Convert.ToInt32(model.NewStaffJoining.PassportCountryIssue); //model.NewStaffJoining.PassportCountryIssue = db.md_type.Where(x => x.Id == countryid).FirstOrDefault().Name; //int deignationid = Convert.ToInt32(model.NewStaffJoining.HRDesignation); //model.NewStaffJoining.HRDesignation = db.hr_designation.Where(x => x.Id == deignationid).FirstOrDefault().des_NameEn; if (model.NewStaffJoining.Id > 0) { unitofwork.NewStaffJoiningRepository.Update(model.NewStaffJoining); unitofwork.Save(); } else { db.NewStaffJoinings.Add(model.NewStaffJoining); db.SaveChanges(); } return(RedirectToAction("Index")); }