Beispiel #1
0
        public async Task <Employee> CreateEmployeeAsync(EmploymentViewModel employee)
        {
            try
            {
                //check if the person is already emplyment
                var results = (await _repository.SearchAsync <Employee>(c => c.PersonId == employee.PersonId)).FirstOrDefault();
                if (results == null)
                {
                    var _employee = Mapper.Map(new Employee(), employee);
                    _employee.LevelTypeId = employee.LevelType.LevelTypeId;
                    _employee.LevelType   = null;
                    var entity = await _repository.AddEntityAsync(_employee);

                    return(entity);
                }
                else
                {
                    throw new Exception("This person is already employed");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Beispiel #2
0
        public async Task <EmploymentViewModel> CreateTaskAsnyc(EmploymentViewModel employmentViewModel)
        {
            try
            {
                if (CheckIntervals(employmentViewModel.EmployeeId, employmentViewModel.HourWorked) == true)
                {
                    employmentViewModel.Duration = TimeSpan.FromHours(employmentViewModel.HourWorked);

                    var _task   = Mapper.Map(new TaskType(), employmentViewModel);
                    var levelId = _repository.Search <Employee>(c => c.EmployeeId == employmentViewModel.EmployeeId).FirstOrDefault().LevelTypeId;
                    var price   = _repository.Search <LevelType>(c => c.LevelTypeId == levelId).
                                  FirstOrDefault().Price;
                    _task.RatePerHour = price;
                    var results = await _repository.AddEntityAsync(_task);

                    return(Mapper.Map(new EmploymentViewModel(), results));
                }
                else
                {
                    throw new Exception("Your tasks are exceeding 12 Hours");
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
        public async Task <IActionResult> Create(EmploymentViewModel model)
        {
            var employment = Mapper.Map <Employment>(model);
            await _proxy.CreateEmployment(employment);

            return(Ok());
        }
        public async Task <IActionResult> Edit(EmploymentViewModel model)
        {
            var emp = Mapper.Map <Employment>(model);
            await _proxy.UpdateEmploymentAsync(emp);

            return(Ok());
        }
Beispiel #5
0
        public ActionResult AddEmploymentInformationSend(EmploymentViewModel eVM)
        {
            if (ModelState.IsValid)
            {
                Person     p = Session["Person"] as Person;
                Employment e = hrServices.CreateEmployment(eVM, p);
                if (e != null)
                {
                    return(RedirectToAction("AddContactPerson"));
                }
                else
                {
                    ModelState.AddModelError("", "Nieznany blad");
                    return(View("AddEmploymentInformation", eVM));
                }
            }
            else
            {
                eVM.Positions      = hrServices.PositionsSelectListItem();
                eVM.Organizations  = hrServices.OrganizationalUnitSelectListItem();
                eVM.ListOfManagers = hrServices.GetAllManagersSelectList();

                return(View("AddEmploymentInformation", eVM));
            }
        }
Beispiel #6
0
        public ActionResult Employment(int?clientId)
        {
            int resolvedClientId      = this.ResolveClientId(clientId);
            EmploymentViewModel model = this.clientProfileManager.GetEmploymentViewModel(resolvedClientId);

            return(this.View(model));
        }
Beispiel #7
0
        public void SaveEmployment(EmploymentViewModel model)
        {
            EmploymentData employment = this.clientProfileService.GetClientEmploymentData(model.ClientId);

            employment.Company      = model.Company;
            employment.HireDate     = model.HireDate;
            employment.Position     = model.Position;
            employment.Salary       = model.Salary;
            employment.IsUnemployed = model.IsUnemployed;
            this.clientProfileService.Save(employment);
        }
Beispiel #8
0
        public double CalculateSalary(EmploymentViewModel employmentViewModel)
        {
            var total = 0.0;
            var tasks = _repository.Search <TaskType>(c => c.EmployeeId == employmentViewModel.EmployeeId).ToList();

            foreach (var item in tasks)
            {
                total += item.RatePerHour;
            }
            return(total);
        }
Beispiel #9
0
        public ActionResult Employment(EmploymentViewModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(model));
            }

            model.ClientId = this.ResolveClientId(model.ClientId);
            this.clientProfileManager.SaveEmployment(model);
            return(this.RedirectToAction("Obligations", new { clientId = model.ClientId }));
        }
        public async Task <IActionResult> GetEmployTable()
        {
            var employ = await _getEmployment.GetEmployTable();

            var employmentViewModel = new EmploymentViewModel()
            {
                EmploymentTables = employ,
                Title            = "Employment Options"
            };

            return(View(employmentViewModel));
        }
Beispiel #11
0
        public ActionResult AddEmploymentInformation()
        {
            EmploymentViewModel eVM = new EmploymentViewModel();

            eVM.Positions      = hrServices.PositionsSelectListItem();
            eVM.Organizations  = hrServices.OrganizationalUnitSelectListItem();
            eVM.ListOfManagers = hrServices.GetAllManagersSelectList();

            /*eVM.Positions = new List<SelectListItem> { new SelectListItem{Text = "Java Developer", Value="1"} } ;
             * eVM.Organizations = new List<SelectListItem> { new SelectListItem { Text = "JAVA TEAM", Value = "1" } };*/

            return(View(eVM));
        }
        public async Task <IActionResult> Employment()
        {
            var getEmp = new GetEmployment();
            var Empl   = await getEmp.GetEmpTable();

            var gradViewModel = new EmploymentViewModel()
            {
                Emp   = Empl,
                Title = "Employment History"
            };

            return(View(gradViewModel));
        }
Beispiel #13
0
        public async Task <Employee> UpdateEmployeeAsync(EmploymentViewModel employee)
        {
            try
            {
                var _employee = Mapper.Map(new Employee(), employee);
                var results   = await _repository.UpdateEntityAsync(_employee);

                return(results);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Beispiel #14
0
        public async Task <EmploymentViewModel> UpdateTaskAsnyc(EmploymentViewModel employmentViewModel)
        {
            try
            {
                var _task   = Mapper.Map(new TaskType(), employmentViewModel);
                var results = await _repository.UpdateEntityAsync(_task);

                return(Mapper.Map(new EmploymentViewModel(), results));
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
Beispiel #15
0
        public IActionResult GetTaskById(int taskId)
        {
            var task  = _taskHandler.GetTaskById(taskId);
            var empVM = new EmploymentViewModel {
                EmployeeId  = task.EmployeeId,
                LevelTypeId = task.TaskTypeId,
                HourWorked  = task.Duration.Hours,
                Description = task.Description,
                RatePerHour = task.RatePerHour,
                TaskTypeId  = task.TaskTypeId
            };

            return(PartialView("_UpdateTaskPartial", empVM));
        }
        //Decrypt
        public static ProfileViewModel DecryptProfile(ProfileViewModel profile)
        {
            profile.Firstname     = StringCipher.Decrypt(profile.Firstname, EncryptKey);
            profile.Lastname      = StringCipher.Decrypt(profile.Lastname, EncryptKey);
            profile.HomeLatitude  = StringCipher.Decrypt(profile.HomeLatitude, EncryptKey);
            profile.HomeLongitude = StringCipher.Decrypt(profile.HomeLongitude, EncryptKey);

            for (int i = 0; i < profile.Employments.Count(); i++)
            {
                EmploymentViewModel e = profile.Employments.ElementAt(i);
                e = DecryptEmployment(e);
            }

            return(profile);
        }
Beispiel #17
0
        public async Task <IActionResult> Employment()
        {
            //populate it with the api call to coop table and need to build the view and model
            var getallemploy = new GetEmploymentInfo();
            var employment   = await getallemploy.EmploymentInfo();

            var sortedEmployment = employment.OrderBy(f => f.city);
            var employViewModel  = new EmploymentViewModel()
            {
                Employment = sortedEmployment.ToList(),
                Title      = "Where our students work"
            };

            return(View(employViewModel));
        }
Beispiel #18
0
        public EmploymentViewModel GetEmploymentViewModel(int clientId)
        {
            EmploymentData employmentData = this.clientProfileService.GetClientEmploymentData(clientId);
            var            model          = new EmploymentViewModel
            {
                ClientId     = clientId,
                IsUnemployed = employmentData.IsUnemployed,
                Company      = employmentData.Company,
                HireDate     = employmentData.HireDate,
                Position     = employmentData.Position,
                Salary       = employmentData.Salary
            };

            return(model);
        }
        public async Task <IActionResult> Employment()
        {
            var empInfo = await _empRepository.GetEmpInfo();

            var coopInfo = await _empRepository.GetCoopInfo();

            var gradViewModel = new EmploymentViewModel()
            {
                EmpInfo  = empInfo,
                CoopInfo = coopInfo,
                Title    = "Employment Table"
            };

            return(View(gradViewModel));
        }
Beispiel #20
0
        public async Task <IActionResult> UpdateTask(EmploymentViewModel employmentViewModel)
        {
            try
            {
                var results = await _taskHandler.UpdateTaskAsnyc(employmentViewModel);

                return(RedirectToAction("Tasks", "Task", new EmploymentViewModel {
                    EmployeeId = results.EmployeeId
                }));
            }
            catch (Exception ex)
            {
                ViewBag.ErrorMessage = ex.Message;
                return(RedirectToAction("Tasks", "Task", new EmploymentViewModel()));
            }
        }
Beispiel #21
0
 public IActionResult Employment(EmploymentViewModel employmentViewModel)
 {
     try
     {
         ViewData["Levels"] = new SelectList(_levelHandler.LevelTypes.Select(u =>
                                                                             new SelectListItem()
         {
             Value = u.LevelTypeId.ToString(), Text = $"{u.Description }"
         }), "Value", "Text");
         return(View(employmentViewModel));
     }
     catch (Exception ex)
     {
         ViewBag.ErrorMessage = ex.Message;
         return(View(employmentViewModel));
     }
 }
Beispiel #22
0
        public ActionResult Edit(int personnelId, int?employmentId)
        {
            int organisationId = UserOrganisationId;

            if (employmentId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var employment = HRBusinessService.RetrievePersonnelEmployment(organisationId, personnelId, employmentId.Value);

            if (employment == null)
            {
                return(HttpNotFound());
            }
            var workingPatternDays               = HRBusinessService.RetrieveWorkingPattern(UserOrganisationId, employment.WorkingPatternId.Value)?.WorkingPatternDays.ToList();
            var absencePolices                   = HRBusinessService.RetrieveAbsencePolices(organisationId);
            var publicHolidayPolices             = HRBusinessService.RetrievePublicHolidayPolices(organisationId);
            var companyBuilding                  = HRBusinessService.RetrieveEmploymentCompanyBuilding(organisationId);
            var employmentTypes                  = HRBusinessService.RetrieveEmploymentTypes(organisationId);
            var jobTitleJobgrades                = HRBusinessService.RetrieveJobTitleJobGrade(organisationId).ToList();
            var defaultSelectedJobTitleJobgrades = jobTitleJobgrades.FirstOrDefault(e => e.JobTitleId == employment.JobTitleId && e.JobGradeId == employment.JobGradeId);
            var viewModel = new EmploymentViewModel
            {
                AbsencePolicyName             = absencePolices.FirstOrDefault(s => s.AbsencePolicyId == employment.AbsencePolicyId).Name,
                AbsencePolicy                 = new SelectList(absencePolices, "AbsencePolicyId", "Name", employment.AbsencePolicyId),
                PublicHolidayPolicy           = new SelectList(publicHolidayPolices, "PublicHolidayPolicyId", "Name", employment.PublicHolidayPolicyId),
                EmploymentType                = new SelectList(employmentTypes, "EmploymentTypeId", "Name", employment.EmploymentTypeId),
                ReportsTo                     = new SelectList(HRBusinessService.RetrieveReportsToPersonnel(organisationId, employment.PersonnelId), "PersonnelId", "Fullname", employment.ReportsToPersonnelId),
                Employment                    = employment,
                SelectedDepartmentIds         = employment.EmploymentDepartments.Select(d => d.DepartmentId).ToList(),
                SelectedTeamIds               = employment.EmploymentTeams.Select(t => t.TeamId).ToList(),
                SelectedCompanyId             = employment.CompanyId.ToString(),
                SelectedBuildingId            = employment.BuildingId.ToString(),
                EmploymentCompanyBuildinglist = companyBuilding,
                WorkingPatternDays            = workingPatternDays,
                PreviousEmployment            = HRBusinessService.RetrievePersonnelCurrentEmployment(organisationId, employment.PersonnelId),
                AbsencePolicyHasAbsence       = HRBusinessService.AbsencePolicyPersonnelEmploymentHasAbsences(organisationId, employment.EmploymentId, employment.AbsencePolicyId),
                JobTitleJobGrades             = jobTitleJobgrades,
                SelectedJobTitleId            = defaultSelectedJobTitleJobgrades.JobTitle.JobTitleId.ToString(),
                SelectedJobGradeId            = defaultSelectedJobTitleJobgrades.JobGrade.JobGradeId.ToString(),
                PreviousAbsencePolicyId       = employment.AbsencePolicyId
            };

            return(View(viewModel));
        }
Beispiel #23
0
        public ActionResult EmploymentForm(int id)
        {
            var employmentInformation  = _context.EmploymentInformations.SingleOrDefault(e => e.Id == id);
            var employmentType         = GetEmploymentTypes();
            var employmentRank         = _context.EmploymentRanks.ToList();
            var employmentBussinesType = _context.NatureOfBusinesses.ToList();

            var viewmodel = new EmploymentViewModel
            {
                EmploymentInformations = employmentInformation,
                EmploymentTypes        = employmentType,
                EmploymentRanks        = employmentRank,
                NatureOfBusinesses     = employmentBussinesType
            };

            return(View(viewmodel));
        }
Beispiel #24
0
        public ActionResult Create(EmploymentViewModel employmentViewModel)
        {
            var organisationId = UserOrganisationId;

            if (employmentViewModel.Employment.StartDate <= employmentViewModel.PreviousEmploymentEndDate)
            {
                ModelState.AddModelError("EmploymentError", "Employment start date should be greater than previous employment End Date");
            }

            if (ModelState.IsValid)
            {
                HRBusinessService.CreateEmployment(organisationId, employmentViewModel.Employment, employmentViewModel.WorkingPatternDays.ToList(), employmentViewModel.SelectedDepartmentIds, employmentViewModel.SelectedTeamIds);
                return(RedirectToAction("Profile", "personnel", new { id = employmentViewModel.Employment.PersonnelId }));
            }
            var previousEmployment               = HRBusinessService.RetrievePersonnelCurrentEmployment(organisationId, employmentViewModel.Employment.PersonnelId);
            var absencePolices                   = HRBusinessService.RetrieveAbsencePolices(organisationId);
            var publicHolidayPolices             = HRBusinessService.RetrievePublicHolidayPolices(organisationId);
            var companyBuilding                  = HRBusinessService.RetrieveEmploymentCompanyBuilding(organisationId).ToList();
            var employmentTypes                  = HRBusinessService.RetrieveEmploymentTypes(organisationId);
            var jobTitleJobgrades                = HRBusinessService.RetrieveJobTitleJobGrade(organisationId).ToList();
            var defaultSelectedJobTitleJobgrades = previousEmployment == null?jobTitleJobgrades.FirstOrDefault() : jobTitleJobgrades.FirstOrDefault(e => e.JobTitleId == employmentViewModel.PreviousEmployment.JobTitleId && e.JobGradeId == employmentViewModel.PreviousEmployment.JobGradeId);

            var viewModel = new EmploymentViewModel
            {
                EmploymentCompanyBuildinglist = companyBuilding,
                SelectedBuildingId            = employmentViewModel.Employment.BuildingId.ToString(),
                SelectedCompanyId             = employmentViewModel.Employment.CompanyId.ToString(),
                SelectedDepartmentIds         = employmentViewModel.SelectedDepartmentIds,
                SelectedTeamIds     = employmentViewModel.SelectedTeamIds,
                ReportsTo           = new SelectList(HRBusinessService.RetrieveReportsToPersonnel(organisationId, employmentViewModel.Employment.PersonnelId), "PersonnelId", "Fullname"),
                EmploymentType      = new SelectList(employmentTypes, "EmploymentTypeId", "Name"),
                AbsencePolicy       = new SelectList(absencePolices, "AbsencePolicyId", "Name", previousEmployment.AbsencePolicyId),
                PublicHolidayPolicy = new SelectList(publicHolidayPolices, "PublicHolidayPolicyId", "Name", previousEmployment.PublicHolidayPolicyId),
                Employment          = employmentViewModel.Employment,
                PreviousEmployment  = previousEmployment,
                WorkingPatternDays  = employmentViewModel.WorkingPatternDays,
                JobTitleJobGrades   = jobTitleJobgrades,
                SelectedJobTitleId  = defaultSelectedJobTitleJobgrades.JobTitle.JobTitleId.ToString(),
                SelectedJobGradeId  = defaultSelectedJobTitleJobgrades.JobGrade.JobGradeId.ToString(),
            };

            return(View(viewModel));
        }
Beispiel #25
0
        public ActionResult UpdatePreviousEmployment(EmploymentViewModel employmentViewModel)
        {
            int organisationId = UserOrganisationId;

            if (ModelState.IsValid)
            {
                var employment = employmentViewModel.PreviousEmployment;
                var result     = HRBusinessService.UpdateEmploymentEndDate(organisationId, employment);
                if (!result.Succeeded)
                {
                    foreach (var error in result.Errors)
                    {
                        ModelState.AddModelError("", error);
                        return(View(employmentViewModel));
                    }
                }
            }
            return(RedirectToAction("Create", new { id = employmentViewModel.PreviousEmployment.PersonnelId }));;
        }
Beispiel #26
0
        public ActionResult Edit(EmploymentViewModel employmentViewModel)
        {
            var organisationId = UserOrganisationId;

            if (ModelState.IsValid)
            {
                employmentViewModel.Employment = HRBusinessService.UpdateEmployment(organisationId, employmentViewModel.Employment, employmentViewModel.PreviousAbsencePolicyId, employmentViewModel.WorkingPatternDays, employmentViewModel.SelectedDepartmentIds,
                                                                                    employmentViewModel.SelectedTeamIds);
                return(RedirectToAction("Profile", "Personnel", new { id = employmentViewModel.Employment.PersonnelId }));
            }
            var employment = HRBusinessService.RetrievePersonnelEmployment(organisationId, employmentViewModel.Employment.PersonnelId, employmentViewModel.Employment.EmploymentId);

            employmentViewModel.Employment.Personnel = employment.Personnel;
            var absencePolices                   = HRBusinessService.RetrieveAbsencePolices(organisationId);
            var publicHolidayPolices             = HRBusinessService.RetrievePublicHolidayPolices(organisationId);
            var companyBuilding                  = HRBusinessService.RetrieveEmploymentCompanyBuilding(organisationId);
            var employmentTypes                  = HRBusinessService.RetrieveEmploymentTypes(organisationId);
            var jobTitleJobgrades                = HRBusinessService.RetrieveJobTitleJobGrade(organisationId).ToList();
            var defaultSelectedJobTitleJobgrades = jobTitleJobgrades.FirstOrDefault(e => e.JobTitleId == employmentViewModel.Employment.JobTitleId && e.JobGradeId == employmentViewModel.Employment.JobGradeId);
            var viewModel = new EmploymentViewModel
            {
                AbsencePolicyName             = absencePolices.FirstOrDefault(s => s.AbsencePolicyId == employmentViewModel.Employment.AbsencePolicyId).Name,
                EmploymentCompanyBuildinglist = companyBuilding,
                SelectedBuildingId            = employment.BuildingId.ToString(),
                SelectedCompanyId             = employment.CompanyId.ToString(),
                AbsencePolicy           = new SelectList(absencePolices, "AbsencePolicyId", "Name", employmentViewModel.Employment.AbsencePolicyId),
                PublicHolidayPolicy     = new SelectList(publicHolidayPolices, "PublicHolidayPolicyId", "Name", employmentViewModel.Employment.PublicHolidayPolicyId),
                ReportsTo               = new SelectList(HRBusinessService.RetrieveReportsToPersonnel(organisationId, employmentViewModel.Employment.PersonnelId), "PersonnelId", "Fullname", employmentViewModel.Employment.ReportsToPersonnelId),
                EmploymentType          = new SelectList(employmentTypes, "EmploymentTypeId", "Name", employment.EmploymentTypeId),
                Employment              = employmentViewModel.Employment,
                SelectedDepartmentIds   = employmentViewModel.SelectedDepartmentIds,
                SelectedTeamIds         = employmentViewModel.SelectedTeamIds,
                WorkingPatternDays      = employmentViewModel.WorkingPatternDays,
                AbsencePolicyHasAbsence = HRBusinessService.AbsencePolicyPersonnelEmploymentHasAbsences(organisationId, employmentViewModel.Employment.EmploymentId, employment.AbsencePolicyId),
                JobTitleJobGrades       = jobTitleJobgrades,
                SelectedJobTitleId      = defaultSelectedJobTitleJobgrades.JobTitle.JobTitleId.ToString(),
                SelectedJobGradeId      = defaultSelectedJobTitleJobgrades.JobGrade.JobGradeId.ToString(),
            };

            return(View(viewModel));
        }
        public async Task <IActionResult> Employment()
        {
            var singleFooter = new GetFooter();
            var footer       = await singleFooter.GetSimpleFooter();

            var getEmployment = new GetEmployment();
            var employment    = await getEmployment.GetAllEmployment();

            var employmentViewModel = new EmploymentViewModel()
            {
                FooterInfo       = footer,
                Introduction     = employment.introduction,
                DegreeStatistics = employment.degreeStatistics,
                Employers        = employment.employers,
                Careers          = employment.careers,
                CoopTable        = employment.coopTable,
                EmploymentTable  = employment.employmentTable,
                Title            = "Employment Information"
            };

            return(View(employmentViewModel));
        }
Beispiel #28
0
        public async Task <IActionResult> EmployementDetails(EmploymentViewModel employmentViewModel)
        {
            try
            {
                if (employmentViewModel.EmploymentType == "employee")
                {
                    await _employeeHandler.CreateEmployeeAsync(employmentViewModel);
                }
                else
                {
                    var employer = Mapper.Map(new Employer(), employmentViewModel);
                    await _employerHandler.CreateEmployeAsync(employer);

                    return(RedirectToAction("Index", "Home"));
                }
                return(RedirectToAction("Employees", "Employment"));
            }
            catch (Exception ex)
            {
                ViewBag.ErrorMessage = ex.Message;
                return(View(new EmploymentViewModel()));
            }
        }
Beispiel #29
0
        public async Task <IActionResult> UpdateEmployement(EmploymentViewModel employmentViewModel)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    if (employmentViewModel.EmploymentType == "employee")
                    {
                        await _employeeHandler.UpdateEmployeeAsync(employmentViewModel);
                    }

                    return(RedirectToAction("Employees", "Employment"));
                }
                catch (Exception ex)
                {
                    ViewBag.ErrorMessage = ex.Message;
                    return(View(employmentViewModel));
                }
            }
            else
            {
                return(View());
            }
        }
Beispiel #30
0
        public ActionResult Create(int personnelId)
        {
            var organisationId       = UserOrganisationId;
            var reportsTo            = HRBusinessService.RetrieveReportsToPersonnel(organisationId, personnelId);
            var employmentTypes      = HRBusinessService.RetrieveEmploymentTypes(organisationId);
            var absencePolices       = HRBusinessService.RetrieveAbsencePolices(organisationId);
            var publicHolidayPolices = HRBusinessService.RetrievePublicHolidayPolices(organisationId);
            var previousEmployment   = HRBusinessService.RetrievePersonnelEmployments(organisationId, personnelId).OrderByDescending(s => s.StartDate).FirstOrDefault();;

            var companyBuilding = HRBusinessService.RetrieveEmploymentCompanyBuilding(organisationId).ToList();
            var defaultSelected = previousEmployment == null?companyBuilding.FirstOrDefault() : companyBuilding.FirstOrDefault(e => e.CompanyId == previousEmployment.CompanyId && e.BuildingId == previousEmployment.BuildingId);

            var jobTitleJobgrades = HRBusinessService.RetrieveJobTitleJobGrade(organisationId).ToList();
            var defaultSelectedJobTitleJobgrades = previousEmployment == null?jobTitleJobgrades.FirstOrDefault() : jobTitleJobgrades.FirstOrDefault(e => e.JobTitleId == previousEmployment.JobTitleId && e.JobGradeId == previousEmployment.JobGradeId);

            var employmentViewModel = new EmploymentViewModel
            {
                EmploymentCompanyBuildinglist = companyBuilding,
                SelectedBuildingId            = defaultSelected.Building.BuildingId.ToString(),
                SelectedCompanyId             = defaultSelected.Company.CompanyId.ToString(),
                JobTitleJobGrades             = jobTitleJobgrades,
                SelectedJobTitleId            = defaultSelectedJobTitleJobgrades.JobTitle.JobTitleId.ToString(),
                SelectedJobGradeId            = defaultSelectedJobTitleJobgrades.JobGrade.JobGradeId.ToString(),
            };

            if (previousEmployment == null)
            {
                employmentViewModel.ReportsTo           = new SelectList(reportsTo, "PersonnelId", "Fullname");
                employmentViewModel.EmploymentType      = new SelectList(employmentTypes, "EmploymentTypeId", "Name");
                employmentViewModel.AbsencePolicy       = new SelectList(absencePolices, "AbsencePolicyId", "Name");
                employmentViewModel.PublicHolidayPolicy = new SelectList(publicHolidayPolices, "PublicHolidayPolicyId", "Name");


                employmentViewModel.Employment = new Employment
                {
                    OrganisationId = organisationId,
                    StartDate      = DateTime.Today,
                    PersonnelId    = personnelId,
                    CompanyId      = defaultSelected.Company.CompanyId,
                    BuildingId     = defaultSelected.Building.BuildingId,
                    JobTitleId     = defaultSelectedJobTitleJobgrades.JobTitle.JobTitleId,
                    JobGradeId     = defaultSelectedJobTitleJobgrades.JobGrade.JobGradeId,
                };
                employmentViewModel.WorkingPatternDays = HRBusinessService.RetrieveDefaultWorkingPatternDays();
            }
            else
            {
                employmentViewModel.ReportsTo = new SelectList(reportsTo, "PersonnelId", "Fullname",
                                                               previousEmployment.ReportsToPersonnelId);
                employmentViewModel.EmploymentType        = new SelectList(employmentTypes, "EmploymentTypeId", "Name", previousEmployment.EmploymentTypeId);
                employmentViewModel.AbsencePolicy         = new SelectList(absencePolices, "AbsencePolicyId", "Name", previousEmployment.AbsencePolicyId);
                employmentViewModel.PublicHolidayPolicy   = new SelectList(publicHolidayPolices, "PublicHolidayPolicyId", "Name", previousEmployment.PublicHolidayPolicyId);
                employmentViewModel.SelectedDepartmentIds = HRBusinessService.RetrieveEmploymentDepartments(organisationId, previousEmployment.EmploymentId)
                                                            .Select(e => e.DepartmentId)
                                                            .ToList();
                employmentViewModel.SelectedTeamIds = HRBusinessService.RetrieveEmploymentTeams(organisationId, previousEmployment.EmploymentId)
                                                      .Select(e => e.TeamId)
                                                      .ToList();

                employmentViewModel.Employment = new Employment
                {
                    StartDate             = (previousEmployment.EndDate ?? new DateTime()).AddDays(1),
                    OrganisationId        = organisationId,
                    PersonnelId           = previousEmployment.PersonnelId,
                    BuildingId            = previousEmployment.BuildingId,
                    ReportsToPersonnelId  = previousEmployment.ReportsToPersonnelId,
                    EndEmploymentReasonId = previousEmployment.EndEmploymentReasonId,
                    WorkingPatternId      = previousEmployment.WorkingPatternId,
                    CompanyId             = previousEmployment.CompanyId,
                    AbsencePolicyId       = previousEmployment.AbsencePolicyId,
                    PublicHolidayPolicyId = previousEmployment.PublicHolidayPolicyId,
                    EmploymentTypeId      = previousEmployment.EmploymentTypeId,
                    JobGradeId            = previousEmployment.JobGradeId,
                    JobTitleId            = previousEmployment.JobTitleId,
                };

                employmentViewModel.PreviousEmployment        = previousEmployment;
                employmentViewModel.WorkingPatternDays        = previousEmployment.WorkingPattern.WorkingPatternDays.ToList();
                employmentViewModel.PreviousEmploymentEndDate = previousEmployment.EndDate;
            }
            return(View(employmentViewModel));
        }