public ActionResult AddNewEmployee() { EmployeeProfile profile = new EmployeeProfile(); if (this.IsAuthorized == "NoAuth") { Response.Redirect("~/Home/Unauthorized"); return(null); } else { using (var client = new OfficeLocationClient()) { var lstOfc = client.GetAllOfficeLocations(); DropDownItem di = new DropDownItem(); ViewBag.EmpOffice = lstOfc.Where(x => x.Key == Convert.ToString(OfficeId)).ToList(); di.Key = ""; di.Value = ""; lstOfc.Insert(0, di); ViewBag.OfficeLocationList = lstOfc; } using (var client = new RoleClient()) { ViewBag.RoleList = client.GetAllRoles(); } using (var client = new ShiftClient()) { ViewBag.ShiftList = client.GetShiftMaster(); } using (var client = new EmployeeClient()) { IList <DropDownItem> reptList = client.GetActiveEmpList(OfficeId, null); DropDownItem di = new DropDownItem { Key = "", Value = "" }; reptList.Insert(0, di); ViewBag.ReportToList = reptList; } profile.EmploymentTypeId = 1; using (var client = new EmployeeClient()) { var lstEmploymentTypes = client.GetEmploymentTypes(); DropDownItem di = new DropDownItem(); ViewBag.EmploymentTypeList = lstEmploymentTypes; } using (var client = new EmployeeClient()) { profile.EmployeeId = client.GetNewEmpId(OfficeId, profile.EmploymentTypeId); } profile.IsActive = true; profile.Mode = "Add"; profile.LogonId = "CORP\\"; profile.Sunday = true; profile.Saturday = true; return(View("EmployeeProfile", profile)); } }
public ActionResult GetShiftMasterDetail() { IList <Shifts> shiftMaster = null; using (var client = new ShiftClient()) { shiftMaster = client.GetShiftMaster(); } return(PartialView("ShiftMasterDetailPartial", shiftMaster)); }
public ActionResult AdminShiftAllocation() { ViewBag.RequestLevelPerson = "Admin"; EmployeeShifts shiftEmployees = new EmployeeShifts(); using (var client = new ShiftClient()) { shiftEmployees.Shifts = client.GetShiftMaster().OrderBy(p => p.FromTime).ToList(); shiftEmployees.shiftEmployees = client.GetShiftDetailsForUsers(this.UserId, "Admin"); } return(View("ShiftAllocation", shiftEmployees)); }
public ActionResult TeamLmsProfile() { EmployeeProfileSearchModel mdl = new EmployeeProfileSearchModel { RequestLevelPerson = "Team", OnlyReportedToMe = true }; using (var client = new ShiftClient()) { ViewBag.ShiftList = client.GetShiftMaster(); } return(View("SearchTeamLmsProfile", mdl)); }
public ActionResult SaveProfile(EmployeeProfile employee) { bool isValid = true; if (ModelState.IsValid) { Regex regex = new Regex(@"^[\w!#$%&'*+\-/=?\^_`{|}~]+(\.[\w!#$%&'*+\-/=?\^_`{|}~]+)*" + "@" + @"((([\-\w]+\.)+[a-zA-Z]{2,4})|(([0-9]{1,3}\.){3}[0-9]{1,3}))$"); if (employee.EmailAddress != null) { if (employee.EmailAddress.Trim() != "") { Match match = regex.Match(employee.EmailAddress); if (!match.Success) { employee.ErrorMesage = "Invalid Email Address format."; isValid = false; } } } if ((!employee.IsActive) && (employee.RelievingDate == null)) { employee.ErrorMesage = "Enter Relieving Date."; isValid = false; } else if (employee.DOJ > employee.RelievingDate) { employee.ErrorMesage = "Relieving Date should be greater than Joining Date."; isValid = false; } else if (employee.DOJ > employee.ConfirmationDate) { employee.ErrorMesage = "Confirmation Date should be greater than Joining Date."; isValid = false; } if (employee.IsActive) { employee.RelievingDate = null; } if (isValid) { employee.LogonId = employee.LogonId.ToUpper(); employee.FirstName = System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(employee.FirstName.ToLower().Trim()); employee.LastName = System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(employee.LastName.ToLower().Trim()); employee.EmailAddress = employee.EmailAddress?.ToLower().Trim(); using (var client = new EmployeeClient()) { string result = client.UpdateEmployeeProfile(employee, UserId); if (result == "Saved") { employee.ErrorMesage = "Saved"; } else if (result == "NeedRole") { employee.ErrorMesage = "Only the user with role 'HR' is allowed to do this action."; } else if (result == "noChanges") { employee.ErrorMesage = "No changes made to Employee Profile."; } else if (result == "Duplicate") { employee.ErrorMesage = "The employee Id already exists."; } else if (result == "DupCorp") { employee.ErrorMesage = "The logon id was already assigned to another employee."; } else if (result == "DupCard") { employee.ErrorMesage = "The card number was already assigned to another employee."; } } } } else { employee.ErrorMesage = "Fix the error messages shown and try to Save again."; } using (var client = new OfficeLocationClient()) { var lstOfc = client.GetAllOfficeLocations(); ViewBag.EmpOffice = lstOfc.Where(x => x.Key == Convert.ToString(OfficeId)).ToList(); DropDownItem di = new DropDownItem { Key = "", Value = "" }; lstOfc.Insert(0, di); ViewBag.OfficeLocationList = lstOfc; } using (var client = new RoleClient()) { ViewBag.RoleList = client.GetAllRoles(); } using (var client = new ShiftClient()) { ViewBag.ShiftList = client.GetShiftMaster(); } using (var client = new EmployeeClient()) { var lstEmploymentTypes = client.GetEmploymentTypes(); DropDownItem di = new DropDownItem { Key = "", Value = "" }; lstEmploymentTypes.Insert(0, di); ViewBag.EmploymentTypeList = lstEmploymentTypes; } using (var client = new EmployeeClient()) { IList <DropDownItem> reptList = new List <DropDownItem>(); if (employee.Mode == "Add") { ViewBag.ReportToList = client.GetActiveEmpList(employee.OfficeId, null); } else { ViewBag.ReportToList = client.GetActiveEmpList(employee.OfficeId, employee.UserId); } DropDownItem di = new DropDownItem { Key = "", Value = "" }; reptList.Insert(0, di); } return(View("EmployeeProfile", employee)); }
public ActionResult ViewProfile() { ViewBag.PageTile = "Employee Profile"; ViewBag.TagLine = ""; ViewBag.IsSelfProfile = true; Int64 userIdForProfile = 0; EmployeeProfile profile = null; if (TempData["UserId"] == null) { userIdForProfile = UserId; } else { userIdForProfile = Convert.ToInt64(TempData["UserId"].ToString()); } using (var client = new EmployeeClient()) { profile = client.GetEmployeeProfile(userIdForProfile); } using (var client = new ShiftClient()) { ViewBag.ShiftList = client.GetShiftMaster(); } using (var client = new OfficeLocationClient()) { List <DropDownItem> lstOfc = client.GetAllOfficeLocations(); DropDownItem di = new DropDownItem(); ViewBag.EmpOffice = lstOfc.Where(x => x.Key == Convert.ToString(OfficeId)).ToList(); di.Key = ""; di.Value = ""; lstOfc.Insert(0, di); ViewBag.OfficeLocationList = lstOfc; } using (var client = new RoleClient()) { ViewBag.RoleList = client.GetAllRoles(); } using (var client = new EmployeeClient()) { var lstEmploymentTypes = client.GetEmploymentTypes(); DropDownItem di = new DropDownItem(); ViewBag.EmploymentTypeList = lstEmploymentTypes; } if (profile != null) { using (var client = new EmployeeClient()) { IList <DropDownItem> reptList = client.GetActiveEmpList(profile.OfficeId, userIdForProfile); DropDownItem di = new DropDownItem { Key = "", Value = "" }; reptList.Insert(0, di); ViewBag.ReportToList = reptList; } } if (TempData["Mode"] == null) { profile.Mode = "View"; } else { profile.Mode = TempData["Mode"].ToString(); } return(View("EmployeeProfile", profile)); }