public async Task <ActionResult> Create(EmployeeViewModel employees, string returnUrl) { Employees realEmployee = new Employees(); var RealUserId = employees.identityCode + employees.empUserId; var EmployeeIdExist = Infrastructure.UserManager.checkEmployeeId(RealUserId); if (ModelState.IsValid && EmployeeIdExist != true) { realEmployee.businessunitId = employees.businessunitId.Value; realEmployee.createdby = null; realEmployee.dateOfJoining = employees.dateOfJoining; realEmployee.dateOfLeaving = employees.dateOfLeaving; realEmployee.departmentId = employees.departmentId.Value; realEmployee.empEmail = employees.empEmail; realEmployee.FullName = employees.FirstName + " " + employees.lastName; realEmployee.empStatusId = employees.empStatusId; realEmployee.isactive = true; realEmployee.jobtitleId = employees.jobtitleId.Value; realEmployee.modeofEmployement = employees.modeofEmployement; realEmployee.modifiedby = null; realEmployee.officeNumber = employees.officeNumber; realEmployee.positionId = realEmployee.positionId; realEmployee.prefixId = employees.prefixId; realEmployee.yearsExp = employees.yearsExp; realEmployee.isactive = true; var CreatedDate = realEmployee.createddate = DateTime.Now; var modifiedDate = realEmployee.modifieddate = DateTime.Now; try { var newCreatedUser = await Infrastructure.UserManager.CreateUser(employees.empEmail, employees.empRoleId.ToString(), employees.empStatusId, employees.FirstName, employees.lastName, employees.officeNumber, RealUserId, employees.jobtitleId.ToString(), null, null, User.Identity.GetUserId(), employees.modeofEmployement.ToString(), employees.dateOfJoining, null, true, employees.departmentId.ToString(), employees.businessunitId.ToString()); if (newCreatedUser.Id != null) { realEmployee.empRoleId = employees.empRoleId; realEmployee.userId = newCreatedUser.Id; empRepo.addEmployees(realEmployee); } } catch (Exception ex) { throw ex; } return(Redirect(returnUrl)); } TempData["Error"] = String.Format($"The employee id already { employees.empUserId} exist in the system"); ViewBag.EmpStatus = new SelectList(statusRepo.GetEmployementStatus().Select(x => new { name = x.employemnt_status, id = x.empstId }).OrderBy(x => x.name), "id", "name", "id"); ViewBag.roles = new SelectList(GetRoles().OrderBy(x => x.Name).Where(u => !u.Name.Contains("System Admin") && !u.Name.Contains("Management") && !u.Name.Contains("Manager")).Select(x => new { name = x.Name, id = x.Id }), "Id", "name", "Id"); ViewBag.prefix = new SelectList(Apimanager.PrefixeList(), "prefixId", "prefixName", "prefixId"); ViewBag.businessUnits = new SelectList(BunitsRepo.GetBusinessUnit().OrderBy(x => x.BusId), "BusId", "unitname", "BusId"); ViewBag.jobTitles = new SelectList(Apimanager.JobList().OrderBy(x => x.JobName), "JobId", "JobName", "JobId"); return(Redirect(returnUrl)); }
public ActionResult Create(string returnUrl) { ViewBag.returnUrl = returnUrl; var result = statusRepo.GetEmployementStatus().Select(x => new { name = x.employemnt_status, id = x.empstId }); ViewBag.EmpStatus = new SelectList(statusRepo.GetEmployementStatus().Select(x => new { name = x.employemnt_status, id = x.empstId }), "id", "name", "id"); ViewBag.roles = new SelectList(GetRoles().OrderBy(x => x.Name).Where(u => !u.Name.Contains("System Admin") && !u.Name.Contains("Management")).Select(x => new { name = x.Name, id = x.Id }), "Id", "name", "Id"); ViewBag.prefix = new SelectList(Apimanager.PrefixeList(), "prefixId", "prefixName", "prefixId"); ViewBag.businessUnits = new SelectList(BunitsRepo.GetBusinessUnit().OrderBy(x => x.BusId), "BusId", "unitname", "BusId"); ViewBag.jobTitles = new SelectList(Apimanager.JobList().OrderBy(x => x.JobName), "JobId", "JobName", "JobId"); return(View()); }
public IHttpActionResult Prefixes() { return(Ok(Apimanager.PrefixeList())); }