// GET: EmployeePIs/Edit/5 public ActionResult MidLevelEdit(int?id) { List <CityMaster> CityList = new List <CityMaster>(); CityList = (from CityName in db.CityMasters select CityName).ToList(); //ViewBag.CountryList = CountryList; ViewBag.LGAextOfKin = new SelectList(CityList, "Id", "City"); List <StateMaster> StateList = new List <StateMaster>(); StateList = (from State in db.StateMasters select State).ToList(); //ViewBag.CountryList = CountryList; ViewBag.StateNextOfKin = new SelectList(StateList, "Id", "State"); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } EmployeePI employeePI = db.EmployeePIs.Find(id); if (employeePI == null) { return(HttpNotFound()); } return(View(employeePI)); }
public ActionResult MidLevelCreate([Bind(Include = "CustomerId,EmployeePIId,EmployeeCode,EmpEmailId,PermanentAddress,MobileNo,EmailIdKin,KinName,AddressNextOfKin,StateNextOfKin,LGAextOfKin,Relation,PhoneNoNextOfKin,NameOfStaffBenificiary,PhoneOfStaffBenificiary,AddressOfStaffBenificiary,EmployeeStatus,CreatedDate,IsDeleted")] EmployeePI employeePI) { try { if (ModelState.IsValid) { int empidcount = (from a in db.EmployeePIs where a.EmployeeCode == employeePI.EmployeeCode select a).Count(); if (empidcount == 0) { int DuplicateEmailMobile = (from a in db.EmployeePIs where a.EmpEmailId == employeePI.EmpEmailId && a.MobileNo == employeePI.MobileNo select a).ToList().Count(); if (DuplicateEmailMobile == 0) { employeePI.CreatedDate = DateTime.Now.Date; db.EmployeePIs.Add(employeePI); db.SaveChanges(); TempData["successmsg"] = "Record is Successfully Added"; TempData["msg"] = ""; int empcode = Convert.ToInt32(@Session["employeecode"]); DateTime dttoday = DateTime.Now.Date; var Role = (from a in db.UserMasters where a.EmployeeCode == empcode select a.RoleId).FirstOrDefault(); var RoleName = (from b in db.RoleMasters where b.RoleId == Role select b.RoleName).FirstOrDefault(); return(RedirectToAction("MidLevelIndex")); //if (RoleName == "Admin" || RoleName == "Super Admin") //{ // return RedirectToAction("Index"); //} //else if (RoleName == "Mid Level Admin") //{ // return RedirectToAction("MidLevelIndex"); //} //else if (RoleName == "Low Level Admin") //{ // return RedirectToAction("MidLevelIndex"); //} //else //{ // return RedirectToAction("UserIndex"); //} } else { TempData["msg"] = "Email Id or Mobile No. is already exist"; return(View(employeePI)); } } } } catch (Exception ext) { TempData["successmsg"] = ""; TempData["msg"] = "Record is not Added,Please try again"; } ViewBag.EmployeeCode = new SelectList(db.EmployeeGIs, "EmployeeCode", "EmployeeCode", employeePI.EmployeeCode); return(View(employeePI)); }
// GET: EmployeePIs/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } EmployeePI employeePI = db.EmployeePIs.Find(id); if (employeePI == null) { return(HttpNotFound()); } return(View(employeePI)); }
public bool CreateEmployeePI(CreateEmployeeDto employeePI) { //_db.EmployeePIs.Add(employeePI); // _db.Addresses.Add(employeePI); // return Save(); EmployeePI employeeData = new EmployeePI(); // parentEntity.Children.Add(new ChildEntity()); // employeeData.Addresses.Add(new Address()); employeeData.Dob = employeePI.DateOfBirth; employeeData.Fname = employeePI.FirstName; employeeData.Lname = employeePI.LastName; employeeData.Oname = employeePI.OtherName; employeeData.Title = employeePI.Title; employeeData.Sex = employeePI.Sex; employeeData.TinNumber = employeePI.TinNumber; employeeData.RNumber = employeePI.RegimentNumber; employeeData.WNumber = employeePI.WorkNumber; employeeData.CNumber = employeePI.CellNumber; employeeData.HNumber = employeePI.HomeNumber; employeeData.PNumber = employeePI.PassportNumber; employeeData.PExpirationDate = employeePI.PassportExpirationDate; employeeData.NidNumber = employeePI.NationalIdNumber; employeeData.EId = employeePI.EthnicityId; employeeData.Email = employeePI.Email; employeeData.MId = employeePI.MaritalStatusId; employeeData.NId = employeePI.NationalityId; employeeData.RId = employeePI.ReligionId; _db.EmployeePIs.Add(employeeData); _db.SaveChanges(); Address addressData = new Address(); addressData.EmployeePI = employeeData; addressData.Lot = employeePI.Lot; addressData.Street = employeePI.Street; addressData.Area = employeePI.Area; addressData.Village = employeePI.Village; addressData.Reg = employeePI.Region; addressData.Ctry = employeePI.Country; _db.Addresses.Add(addressData); _db.SaveChanges(); return(Save()); }
public ActionResult MidLevelEdit([Bind(Include = "EmployeePIId,EmployeeCode,EmpEmailId,PermanentAddress,MobileNo,EmailIdKin,KinName,AddressNextOfKin,StateNextOfKin,LGAextOfKin,Relation,PhoneNoNextOfKin,NameOfStaffBenificiary,PhoneOfStaffBenificiary,AddressOfStaffBenificiary,EmployeeStatus,CreatedDate,IsDeleted")] EmployeePI employeePI) { try { if (ModelState.IsValid) { employeePI.EmployeePIId = (from a in db.EmployeePIs where a.EmployeeCode == employeePI.EmployeeCode select a.EmployeePIId).FirstOrDefault(); employeePI.CreatedDate = DateTime.Now; employeePI.IsDeleted = false; db.Entry(employeePI).State = EntityState.Modified; db.SaveChanges(); TempData["successmsg"] = "Record is Successfully Updated"; TempData["msg"] = ""; int empcode = Convert.ToInt32(@Session["employeecode"]); DateTime dttoday = DateTime.Now.Date; var Role = (from a in db.UserMasters where a.EmployeeCode == empcode select a.RoleId).FirstOrDefault(); var RoleName = (from b in db.RoleMasters where b.RoleId == Role select b.RoleName).FirstOrDefault(); return(RedirectToAction("MidLevelIndex")); //if (RoleName == "Admin" || RoleName == "Super Admin") //{ // return RedirectToAction("Index"); //} //else if (RoleName == "Mid Level Admin") //{ // return RedirectToAction("MidLevelIndex"); //} //else if (RoleName == "Low Level Admin") //{ // return RedirectToAction("MidLevelIndex"); //} //else //{ // return RedirectToAction("UserIndex"); //} } } catch (Exception ext) { TempData["msg"] = "Record is not Updated,Try again"; TempData["successmsg"] = ""; } ViewBag.EmployeeCode = new SelectList(db.EmployeeGIs, "EmployeeCode", "EmployeeCode", employeePI.EmployeeCode); return(View(employeePI)); }
public ActionResult DeleteConfirmed(int id) { try { EmployeePI employeePI = db.EmployeePIs.Find(id); db.EmployeePIs.Remove(employeePI); db.SaveChanges(); TempData["successmsg"] = "Record is Successfully Deleted"; TempData["msg"] = ""; return(RedirectToAction("Index")); } catch (Exception ext) { TempData["successmsg"] = ""; TempData["msg"] = "Record is not Deleted,Try again"; return(RedirectToAction("Index")); } }
public bool UpdateEmployeePI(EmployeePI employeePI) { _db.EmployeePIs.Update(employeePI); return(Save()); }
public bool DeleteEmployeePI(EmployeePI employeePI) { _db.EmployeePIs.Remove(employeePI); return(Save()); }
public bool CreateEmployeePI(EmployeePI employeePI) { _db.EmployeePIs.Add(employeePI); return(Save()); }