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 Jobs() { var result = Apimanager.JobList(); if (result == null) { var emptyResult = new { Message = "No file Found" }; return(Ok(emptyResult)); } else { return(Ok(result)); } }
public ActionResult addPosition(Positions model, string returnUrl) { try { if (ModelState.IsValid) { Positions position = model; position.createdby = null; // int.Parse(User.Identity.GetUserId()); position.modifiedby = null; //int.Parse(User.Identity.GetUserId()); position.modifieddate = DateTime.Now; positionRepo.AddPosition(position); ModelState.Clear(); TempData["Success"] = string.Format($"{position.positionname} has been created"); return(Redirect(returnUrl)); } ViewBag.jobTitles = new SelectList(Apimanager.JobList().OrderBy(x => x.JobName), "JobId", "JobName", "JobId"); TempData["Error"] = "Something went wrong. please make sure you fill all the appropriate details"; return(PartialView(model)); } catch (Exception ex) { throw ex; } }
public PartialViewResult addPosition(string returnUrl) { ViewBag.returnUrl = returnUrl; ViewBag.jobTitles = new SelectList(Apimanager.JobList().OrderBy(x => x.JobName), "JobId", "JobName", "JobId"); return(PartialView(new Positions())); }