public ActionResult Edit(int id, SalaryScale salaryScale) { var salaryScaleToEdit = _salaryScaleRepository.GetNullableById(id); if (salaryScaleToEdit == null) { return(RedirectToAction("Index")); } TransferValues(salaryScale, salaryScaleToEdit); if (ModelState.IsValid) { _salaryScaleRepository.EnsurePersistent(salaryScaleToEdit); Message = "SalaryScale Edited Successfully"; return(RedirectToAction("Index")); } else { var viewModel = SalaryScaleViewModel.Create(Repository); viewModel.SalaryScale = salaryScale; return(View(viewModel)); } }
public ActionResult DeleteConfirmed(int id) { SalaryScale salaryScale = db.SalaryScales.Find(id); db.SalaryScales.Remove(salaryScale); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "SalaryScaleID,SalaryScaleName,SalaryAmount")] SalaryScale salaryScale) { if (ModelState.IsValid) { db.Entry(salaryScale).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(salaryScale)); }
public ActionResult Create([Bind(Include = "SalaryScaleID,SalaryScaleName,SalaryAmount")] SalaryScale salaryScale) { if (ModelState.IsValid) { db.SalaryScales.Add(salaryScale); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(salaryScale)); }
// GET: SalaryScales/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SalaryScale salaryScale = db.SalaryScales.Find(id); if (salaryScale == null) { return(HttpNotFound()); } return(View(salaryScale)); }
public ActionResult Delete(int id, SalaryScale salaryScale) { var salaryScaleToDelete = _salaryScaleRepository.GetNullableById(id); if (salaryScaleToDelete == null) { return(RedirectToAction("Index")); } _salaryScaleRepository.Remove(salaryScaleToDelete); Message = "SalaryScale Removed Successfully"; return(RedirectToAction("Index")); }
public async Task <IActionResult> AddSalaryScale(SalaryScale item) { var x = await _context.SalaryScales.FirstOrDefaultAsync(b => b.SalaryScaleTypeId == item.SalaryScaleTypeId && b.IsActive); if (x != null) { x.ThruDate = item.FromDate.AddDays(-1); x.IsActive = false; } item.UpdatedBy = "user"; _context.SalaryScales.Add(item); await _context.SaveChangesAsync(); return(RedirectToAction("SalaryScalesList")); }
public static SalaryScaleViewModel Create(IRepository repository, string titleCode, string effectiveDate, User user) { Check.Require(repository != null, "Repository must be supplied"); var viewModel = new SalaryScaleViewModel { SalaryScale = new SalaryScale(), Titles = repository.OfType <Title>() .Queryable .OrderBy(t => t.AbbreviatedName) // .ThenBy(t => t.TitleCode) .ToList() }; viewModel.TitleCodes = viewModel.Titles .OrderBy(t => t.TitleCode) .ToList(); if (!String.IsNullOrEmpty(titleCode)) { var searchDate = DateTime.Now; if (effectiveDate != null) { DateTime.TryParse(effectiveDate, out searchDate); } var salaryScale = SalaryScale.GetEffectiveSalaryScale(repository, titleCode, searchDate); if (salaryScale != null) { viewModel.SalaryScale = salaryScale; } viewModel.TitleCode = titleCode; var schoolsForUser = user.Units.Select(x => x.DeansOfficeSchoolCode).Distinct().ToArray(); viewModel.CollegeAverages = repository.OfType <CollegeAverage>().Queryable.Where(x => schoolsForUser.Contains(x.SchoolCode) && x.TitleCode == viewModel.TitleCode). ToList(); } return(viewModel); }
public ActionResult Create(SalaryScale salaryScale) { var salaryScaleToCreate = new SalaryScale(); TransferValues(salaryScale, salaryScaleToCreate); if (ModelState.IsValid) { _salaryScaleRepository.EnsurePersistent(salaryScaleToCreate); Message = "SalaryScale Created Successfully"; return(RedirectToAction("Index")); } else { var viewModel = SalaryScaleViewModel.Create(Repository); viewModel.SalaryScale = salaryScale; return(View(viewModel)); } }
public ActionResult Create(SalaryScale salaryScale) { var salaryScaleToCreate = new SalaryScale(); TransferValues(salaryScale, salaryScaleToCreate); if (ModelState.IsValid) { _salaryScaleRepository.EnsurePersistent(salaryScaleToCreate); Message = "SalaryScale Created Successfully"; return RedirectToAction("Index"); } else { var viewModel = SalaryScaleViewModel.Create(Repository); viewModel.SalaryScale = salaryScale; return View(viewModel); } }
public ActionResult CreateEdit(SalaryReviewAnalysis salaryReviewAnalysis, SRAEmployee sraEmployee) { const string MESSAGE_RECORD_UPDATED_SUCCESS = "Salary Review Analysis Successfully Updated "; const string MESSAGE_RECORD_SAVED_SUCCESS = "Salary Review Analysis Successfully Saved "; var message = MESSAGE_RECORD_SAVED_SUCCESS; var scenarios = salaryReviewAnalysis.Scenarios.Select(item => UpdateScenarioValues(item)).ToList(); var dateApproved = salaryReviewAnalysis.DateApproved; //if (gvSalaryReviewAnaysis.Rows.Count == 1) //{ // // Get date approved: // TextBox tbDateApproved = gvSalaryReviewAnaysis.Rows[0].FindControl("tbDateApproved") as TextBox; // if (tbDateApproved != null) // { // dateApproved = tbDateApproved.Text; // } //} //dateApproved = salaryReviewAnalysis.DateApproved; //var user = Esra.Core.Domain.User.GetByLoginId(Repository, CurrentUser.Identity.Name); var user = GetUser(); //var sra = (String.IsNullOrEmpty(ReferenceNum) == false ? SalaryReviewAnalysisBLL.GetByReferenceNumber(ReferenceNum) : null); var salaryReviewAnalysisToEdit = (String.IsNullOrEmpty(salaryReviewAnalysis.ReferenceNumber) == false ? _salaryReviewAnalysisRepository .Queryable .Where(x => x.ReferenceNumber.Equals(salaryReviewAnalysis.ReferenceNumber)) .FirstOrDefault() : null); var emp = (salaryReviewAnalysisToEdit != null ? salaryReviewAnalysisToEdit.Employee : new SRAEmployee(Repository.OfType <Employee>().Queryable.Where(x => x.Id.Equals(sraEmployee.PkEmployee)).FirstOrDefault())); //bool isReclass = (ProposedTitleCode != null && ProposedTitleCode.Equals(emp.TitleCode) == false ? true : false); var isReclass = salaryReviewAnalysis.IsReclass; //string titleCode = (isReclass ? ProposedTitleCode : emp.TitleCode); var titleCode = salaryReviewAnalysis.Title.TitleCode; if (salaryReviewAnalysisToEdit != null) { // Then this is an existing analysis: // Record exists --> Update message = MESSAGE_RECORD_UPDATED_SUCCESS; } else { // Else this is a new analysis: salaryReviewAnalysisToEdit = new SalaryReviewAnalysis() { DateInitiated = DateTime.Today, //InitiatedByReviewerName = user.FullName, //OriginatingDepartment = Department.GetOriginatingDepartmentForUser(Repository, user.EmployeeID), Title = Repository.OfType <Title>() .Queryable .Where(t => t.TitleCode.Equals(titleCode)) .FirstOrDefault(), Employee = emp, SalaryScale = SalaryScale.GetEffectiveSalaryScale(Repository, titleCode, DateTime.Today), CurrentTitleCode = emp.TitleCode, IsReclass = isReclass }; } salaryReviewAnalysisToEdit.InitiatedByReviewerName = salaryReviewAnalysis.InitiatedByReviewerName; salaryReviewAnalysisToEdit.OriginatingDepartment = salaryReviewAnalysis.OriginatingDepartment; //if (String.IsNullOrEmpty(dateApproved) == false) salaryReviewAnalysisToEdit.DateApproved = dateApproved ?? null; salaryReviewAnalysisToEdit.DeansOfficeComments = salaryReviewAnalysis.DeansOfficeComments; salaryReviewAnalysisToEdit.DepartmentComments = salaryReviewAnalysis.DepartmentComments; salaryReviewAnalysisToEdit.Scenarios = scenarios; //TransferValues(salaryReviewAnalysis, salaryReviewAnalysisToEdit); if (ModelState.IsValid) { //_salaryReviewAnalysisRepository.EnsurePersistent(salaryReviewAnalysisToEdit); SalaryReviewAnalysis.UpdateRecord(Repository, salaryReviewAnalysisToEdit); // At this point the reference number has been if a newly created analysis! //Session["Message"] = message; var referenceNumber = salaryReviewAnalysisToEdit.ReferenceNumber; Message = Message = "Salary Review Analysis (ref #: " + referenceNumber + ") Successfully Saved";; //var values = new System.Web.Routing.RouteValueDictionary { { "referenceNumber", referenceNumber } }; //return RedirectToAction("Details", values); // -- or -- //return RedirectToAction("Details", new { referenceNumber }); // -- or -- return(this.RedirectToAction <SalaryReviewAnalysisController>(a => a.Details(referenceNumber))); } else { var viewModel = SalaryReviewAnalysisViewModel.Create(Repository); viewModel.SalaryReviewAnalysis = salaryReviewAnalysis; return(View(viewModel)); } }
/// <summary> /// Transfer editable values from source to destination /// </summary> private static void TransferValues(SalaryScale source, SalaryScale destination) { //Recommendation: Use AutoMapper //Mapper.Map(source, destination) throw new NotImplementedException(); }
/// <summary> /// Given a repository, employee ID, proposed title (optional) and user /// or repository, reference number, and user, /// Create a Salary Analysis Editor View model. /// </summary> /// <param name="repository">Database IRepository context</param> /// <param name="selectedEmployeeId">Employee ID of the employee for which to perform a new salary review analysis upon</param> /// <param name="proposedTitle">The proposed title to be used in conjunction with performing for a reclassification review; otherwise, null when performing an equity review</param> /// <param name="referenceNumber">The Salary Review Analysis reference number to be used for looking up an existing analysis</param> /// <param name="user">The logged in user either creating a new or viewing an existing analysis. Used for determining which college average(s) to display on the associated Salary Scale</param> /// <returns>A SalaryReviewAnalysisEditorViewModel populated according to the parameters provided</returns> public static SalaryReviewAnalysisEditorViewModel Create(IRepository repository, string selectedEmployeeId, string proposedTitle, string referenceNumber, User user) { Check.Require(repository != null, "Repository must be supplied"); var viewModel = new SalaryReviewAnalysisEditorViewModel { ProposedTitles = repository.OfType <Title>() .Queryable .OrderBy(t => t.AbbreviatedName) // .ThenBy(t => t.TitleCode) .ToList(), //SelectionTypes = repository.OfType<SelectionType>() //.Queryable //.Where(x => x.ShortType != "Step") //.OrderBy(s => s.SortOrder) //.ToList(), ReportDate = DateTime.Today }; var salaryScaleViewModel = new SalaryScaleViewModel(); SalaryReviewAnalysis salaryReviewAnalysis = null; SalaryScale salaryScale = null; string titleCode = null; // This title code is used in conjunction with determining colleges averages. if (!String.IsNullOrEmpty(referenceNumber) || !String.IsNullOrEmpty(selectedEmployeeId)) { // Assumes either an employee ID or reference number was provided. // We should always get here unless someone bypassed the menu page and entered a URL directly into // a web browser with some or all parameters missing. if (String.IsNullOrEmpty(referenceNumber)) { // Then an employee ID and proposed title for reclassification (optional) was provided viewModel.ReportDate = DateTime.Today; viewModel.SelectedEmployee = repository.OfType <Employee>() .Queryable .Where(e => e.id.Equals(selectedEmployeeId)) .FirstOrDefault(); salaryReviewAnalysis = new SalaryReviewAnalysis { DateInitiated = DateTime.Today }; var scenarios = new List <Scenario>(); var scenario = new Scenario { SalaryReviewAnalysis = salaryReviewAnalysis, ScenarioNumber = 1, SelectionType = "None", PercentIncrease = 0, Approved = false, SalaryAmount = viewModel.SelectedEmployee.PayRate }; scenarios.Add(scenario); salaryReviewAnalysis.Scenarios = scenarios; viewModel.SalaryReviewAnalysis = salaryReviewAnalysis; viewModel.SraEmployee = new SRAEmployee(viewModel.SelectedEmployee); salaryScale = new SalaryScale(); if (string.IsNullOrEmpty(proposedTitle) == false && !viewModel.SelectedEmployee.TitleCode.Equals(proposedTitle)) { // Then the optional proposed title was provided so this is a reclassification review. titleCode = proposedTitle; viewModel.SalaryReviewAnalysis.IsReclass = true; viewModel.ProposedTitle = repository.OfType <Title>() .Queryable .Where(p => p.TitleCode.Equals(proposedTitle)) .FirstOrDefault(); //salaryScale = repository.OfType<SalaryScale>() // .Queryable // .Where(r => r.TitleCode == proposedTitle) // .FirstOrDefault(); salaryScale = SalaryScale.GetEffectiveSalaryScale(repository, proposedTitle, DateTime.Today); viewModel.SalaryReviewAnalysis.Title = viewModel.ProposedTitle; } else { // Else this is a standard equity review. titleCode = viewModel.SelectedEmployee.TitleCode; //salaryScale = repository.OfType<SalaryScale>() // .Queryable // .Where(r => r.TitleCode == viewModel.SelectedEmployee.TitleCode) // .FirstOrDefault(); salaryScale = SalaryScale.GetEffectiveSalaryScale(repository, viewModel.SelectedEmployee.TitleCode, DateTime.Today); viewModel.SalaryReviewAnalysis.Title = viewModel.SelectedEmployee.Title; } } else if (!String.IsNullOrEmpty(referenceNumber)) { // Reference number is present so try getting existing review by reference number: viewModel.SalaryReviewAnalysis = repository.OfType <SalaryReviewAnalysis>() .Queryable .Where(x => x.ReferenceNumber.Equals(referenceNumber)) .FirstOrDefault(); if (viewModel.SalaryReviewAnalysis != null) { titleCode = viewModel.SalaryReviewAnalysis.SalaryScale.TitleCode; viewModel.SraEmployee = viewModel.SalaryReviewAnalysis.Employee; viewModel.ProposedTitle = (viewModel.SalaryReviewAnalysis.IsReclass ? viewModel.SalaryReviewAnalysis.Title : null); salaryScale = SalaryScale.GetEffectiveSalaryScale(repository, viewModel.SalaryReviewAnalysis.SalaryScale.TitleCode, viewModel.SalaryReviewAnalysis.SalaryScale.EffectiveDate); } } if (salaryScale != null) { // Determine the user's school(s) var schoolsForUser = user.Units.Select(x => x.DeansOfficeSchoolCode).Distinct().ToArray(); // and populate the corresponding college averages: salaryScaleViewModel.CollegeAverages = repository.OfType <CollegeAverage>().Queryable.Where(x => schoolsForUser.Contains(x.SchoolCode) && x.TitleCode == titleCode). ToList(); var employeesSchoolCode = viewModel.SraEmployee.HomeDepartment.SchoolCode; var collegeAverage = salaryScaleViewModel.CollegeAverages.Where(x => x.SchoolCode.Equals(employeesSchoolCode)).Select(x => x.CollegeAverageAnnual). FirstOrDefault(); viewModel.CriteriaList = SalaryReviewAnalysis.GetCriteriaList(repository, salaryScale, collegeAverage); salaryScaleViewModel.SalaryScale = salaryScale; } } viewModel.SalaryScaleViewModel = salaryScaleViewModel; return(viewModel); }
// GET: /EmployeeSalaryComparison/Details public ActionResult Details(string[] selectedTitleCodes, string[] selectedDepartmentCodes, string selectedEmployeeId) { var isDepartmentUser = IsDepartmentUser; var user = Core.Domain.User.GetByLoginId(Repository, CurrentUser.Identity.Name); var employeeSalaryComparisonModel = Models.EmployeeSalaryComparisonViewModel.Create(Repository, user, isDepartmentUser, null); var isAnyTitle = true; var isAnyDepartment = true; var isAnyEmployee = true; var hasSelectedTitleCodes = selectedTitleCodes == null || selectedTitleCodes.Length == 0 || selectedTitleCodes[0].Equals("0") || selectedTitleCodes[0].Equals(String.Empty) ? false : true; var hasSelectedDepartmentCodes = selectedDepartmentCodes == null || selectedDepartmentCodes.Length == 0 || selectedDepartmentCodes[0].Equals("0") || selectedDepartmentCodes[0].Equals(String.Empty) ? false : true; var hasSelectedEmployeeId = String.IsNullOrEmpty(selectedEmployeeId) || selectedEmployeeId.Equals("0") || selectedEmployeeId.Equals(String.Empty) ? false : true; var mySelectedTitleCodes = new List <string>(); if (selectedTitleCodes != null) { foreach (var i in selectedTitleCodes) { var j = i.Split(','); foreach (var s in j) { mySelectedTitleCodes.Add(s.Trim()); } } selectedTitleCodes = mySelectedTitleCodes.ToArray(); } // search expression example: //employeeSalaryComparisonModel.EmployeeSalaryComparisonSearchExpression = // employeeSalaryComparisonModel.EmployeeSalaryComparisonSearchExpression.And( // p => p.Employee.PkEmployee == viewModel.SelectedEmployee.id); var allSchoolEmployees = employeeSalaryComparisonModel.AllSchoolEmployees; var employees = new List <Employee>(); if (hasSelectedEmployeeId) { // get the employee by employee ID: employees = allSchoolEmployees.Where(r => selectedEmployeeId.Equals(r.Id)).ToList(); if (employees.Count == 1) { var employee = employees[0]; //var salaryScale = _salaryScaleRepository // .Queryable.Where(r => r.TitleCode == employees[0].TitleCode).FirstOrDefault(); //if (salaryScale != null) //{ // salaryScale.SalarySteps = Repository.OfType<SalaryStep>() // .Queryable // .Where( // s => // s.TitleCode == salaryScale.TitleCode && s.EffectiveDate == salaryScale.EffectiveDate) // .ToList(); // employeeSalaryComparisonModel.SalaryScaleViewModel.SalaryScale = salaryScale; employeeSalaryComparisonModel.SalaryScaleViewModel.SalaryScale = SalaryScale.GetEffectiveSalaryScale(Repository, employee.TitleCode, DateTime.Now); var schoolsForUser = user.Units.Select(x => x.DeansOfficeSchoolCode).Distinct().ToArray(); employeeSalaryComparisonModel.SalaryScaleViewModel.CollegeAverages = Repository.OfType <CollegeAverage>().Queryable.Where(x => schoolsForUser.Contains(x.SchoolCode) && x.TitleCode == employee.TitleCode). ToList(); } isAnyEmployee = false; } else { // if both are null; get them all if (!hasSelectedDepartmentCodes && !hasSelectedTitleCodes) { // get all records: employees = allSchoolEmployees.ToList(); } else if (hasSelectedDepartmentCodes && !hasSelectedTitleCodes) { // get those with matching department codes: employees = allSchoolEmployees.Where(r => selectedDepartmentCodes.Contains(r.HomeDepartmentID)).ToList(); employeeSalaryComparisonModel.SelectedDepartmentCodesString = PipeDelimittedString.ArrayToPipeDelimittedString(selectedDepartmentCodes); isAnyDepartment = false; } else if (!hasSelectedDepartmentCodes && hasSelectedTitleCodes) { // get those with matching title codes: employees = allSchoolEmployees.Where(r => selectedTitleCodes.Contains(r.TitleCode)).ToList(); //var salaryScales = _salaryScaleRepository // .Queryable.Where(r => selectedTitleCodes.Contains(r.TitleCode)).ToList(); if (selectedTitleCodes.Count() == 1) { var titleCode = selectedTitleCodes[0]; //var salaryScale = salaryScales[0]; //salaryScale.SalarySteps = Repository.OfType<SalaryStep>() // .Queryable // .Where( // s => // s.TitleCode == salaryScale.TitleCode && s.EffectiveDate == salaryScale.EffectiveDate) // .ToList(); //employeeSalaryComparisonModel.SalaryScaleViewModel.SalaryScale = salaryScale; employeeSalaryComparisonModel.SalaryScaleViewModel.SalaryScale = SalaryScale.GetEffectiveSalaryScale(Repository, titleCode, DateTime.Now); var schoolsForUser = user.Units.Select(x => x.DeansOfficeSchoolCode).Distinct().ToArray(); employeeSalaryComparisonModel.SalaryScaleViewModel.CollegeAverages = Repository.OfType <CollegeAverage>().Queryable.Where(x => schoolsForUser.Contains(x.SchoolCode) && x.TitleCode == titleCode). ToList(); } employeeSalaryComparisonModel.SelectedTitleCodesString = PipeDelimittedString.ArrayToPipeDelimittedString(selectedTitleCodes); isAnyTitle = false; } else { // get those with matching department and title codes: employees = allSchoolEmployees.Where( r => selectedTitleCodes.Contains(r.TitleCode) && selectedDepartmentCodes.Contains(r.HomeDepartmentID)).ToList(); //var salaryScales = _salaryScaleRepository // .Queryable.Where(r => selectedTitleCodes.Contains(r.TitleCode)).ToList(); if (selectedTitleCodes.Count() == 1) { var titleCode = selectedTitleCodes[0]; //var salaryScale = salaryScales[0]; //salaryScale.SalarySteps = Repository.OfType<SalaryStep>() // .Queryable // .Where( // s => // s.TitleCode == salaryScale.TitleCode && s.EffectiveDate == salaryScale.EffectiveDate) // .ToList(); //employeeSalaryComparisonModel.SalaryScaleViewModel.SalaryScale = salaryScale; employeeSalaryComparisonModel.SalaryScaleViewModel.SalaryScale = SalaryScale.GetEffectiveSalaryScale(Repository, titleCode, DateTime.Now); var schoolsForUser = user.Units.Select(x => x.DeansOfficeSchoolCode).Distinct().ToArray(); employeeSalaryComparisonModel.SalaryScaleViewModel.CollegeAverages = Repository.OfType <CollegeAverage>().Queryable.Where(x => schoolsForUser.Contains(x.SchoolCode) && x.TitleCode == titleCode). ToList(); } employeeSalaryComparisonModel.SelectedDepartmentCodesString = PipeDelimittedString.ArrayToPipeDelimittedString(selectedDepartmentCodes); employeeSalaryComparisonModel.SelectedTitleCodesString = PipeDelimittedString.ArrayToPipeDelimittedString(selectedTitleCodes); isAnyDepartment = false; isAnyTitle = false; } } employeeSalaryComparisonModel.Employees = employees; // Logic for initializing ESR Search Parameters: employeeSalaryComparisonModel.EsrSearchParameters = new ESRSearchParameters() { SearchEmployee = employeeSalaryComparisonModel.SelectedEmployee, SearchTitles = employeeSalaryComparisonModel.SelectedTitles.ToList(), SearchDepartments = employeeSalaryComparisonModel.SelectedDepartments.ToList() }; if (!isAnyEmployee) { employeeSalaryComparisonModel.SelectedEmployee = employeeSalaryComparisonModel.EmployeesList.Where( r => selectedEmployeeId.Equals(r.id)).FirstOrDefault(); employeeSalaryComparisonModel.EsrSearchParameters.SearchEmployee = employeeSalaryComparisonModel.SelectedEmployee; } if (!isAnyDepartment) { employeeSalaryComparisonModel.SelectedDepartments = employeeSalaryComparisonModel.DepartmentsList.Where( r => selectedDepartmentCodes.Contains(r.DepartmentNumber)).OrderBy(r => r.Name).ToList(); employeeSalaryComparisonModel.EsrSearchParameters.SearchDepartments = employeeSalaryComparisonModel.SelectedDepartments.ToList(); } if (!isAnyTitle) { employeeSalaryComparisonModel.SelectedTitles = employeeSalaryComparisonModel.TitlesList.Where( r => selectedTitleCodes.Contains(r.TitleCode)).OrderBy(r => r.AbbreviatedName).ToList(); employeeSalaryComparisonModel.EsrSearchParameters.SearchTitles = employeeSalaryComparisonModel.SelectedTitles.ToList(); } //if (employee == null) return RedirectToAction("Index"); return(View(employeeSalaryComparisonModel)); }
public ActionResult Delete(int id, SalaryScale salaryScale) { var salaryScaleToDelete = _salaryScaleRepository.GetNullableById(id); if (salaryScaleToDelete == null) return RedirectToAction("Index"); _salaryScaleRepository.Remove(salaryScaleToDelete); Message = "SalaryScale Removed Successfully"; return RedirectToAction("Index"); }
/// <summary> /// Given a repository, employee ID, proposed title (optional) and user /// or repository, reference number, and user, /// Create a Salary Analysis Editor View model. /// </summary> /// <param name="repository">Database IRepository context</param> /// <param name="selectedEmployeeId">Employee ID of the employee for which to perform a new salary review analysis upon</param> /// <param name="proposedTitle">The proposed title to be used in conjunction with performing for a reclassification review; otherwise, null when performing an equity review</param> /// <param name="referenceNumber">The Salary Review Analysis reference number to be used for looking up an existing analysis</param> /// <param name="user">The logged in user either creating a new or viewing an existing analysis. Used for determining which college average(s) to display on the associated Salary Scale</param> /// <returns>A SalaryReviewAnalysisEditorViewModel populated according to the parameters provided</returns> public static SalaryReviewAnalysisEditorViewModel Create(IRepository repository, string selectedEmployeeId, string proposedTitle, string referenceNumber, User user) { Check.Require(repository != null, "Repository must be supplied"); var viewModel = new SalaryReviewAnalysisEditorViewModel { ProposedTitles = repository.OfType<Title>() .Queryable .OrderBy(t => t.AbbreviatedName) // .ThenBy(t => t.TitleCode) .ToList(), //SelectionTypes = repository.OfType<SelectionType>() //.Queryable //.Where(x => x.ShortType != "Step") //.OrderBy(s => s.SortOrder) //.ToList(), ReportDate = DateTime.Today }; var salaryScaleViewModel = new SalaryScaleViewModel(); SalaryReviewAnalysis salaryReviewAnalysis = null; SalaryScale salaryScale = null; string titleCode = null; // This title code is used in conjunction with determining colleges averages. if (!String.IsNullOrEmpty(referenceNumber) || !String.IsNullOrEmpty(selectedEmployeeId)) { // Assumes either an employee ID or reference number was provided. // We should always get here unless someone bypassed the menu page and entered a URL directly into // a web browser with some or all parameters missing. if (String.IsNullOrEmpty(referenceNumber)) { // Then an employee ID and proposed title for reclassification (optional) was provided viewModel.ReportDate = DateTime.Today; viewModel.SelectedEmployee = repository.OfType<Employee>() .Queryable .Where(e => e.id.Equals(selectedEmployeeId)) .FirstOrDefault(); salaryReviewAnalysis = new SalaryReviewAnalysis { DateInitiated = DateTime.Today }; var scenarios = new List<Scenario>(); var scenario = new Scenario { SalaryReviewAnalysis = salaryReviewAnalysis, ScenarioNumber = 1, SelectionType = "None", PercentIncrease = 0, Approved = false, SalaryAmount = viewModel.SelectedEmployee.PayRate }; scenarios.Add(scenario); salaryReviewAnalysis.Scenarios = scenarios; viewModel.SalaryReviewAnalysis = salaryReviewAnalysis; viewModel.SraEmployee = new SRAEmployee(viewModel.SelectedEmployee); salaryScale = new SalaryScale(); if (string.IsNullOrEmpty(proposedTitle) == false && !viewModel.SelectedEmployee.TitleCode.Equals(proposedTitle)) { // Then the optional proposed title was provided so this is a reclassification review. titleCode = proposedTitle; viewModel.SalaryReviewAnalysis.IsReclass = true; viewModel.ProposedTitle = repository.OfType<Title>() .Queryable .Where(p => p.TitleCode.Equals(proposedTitle)) .FirstOrDefault(); //salaryScale = repository.OfType<SalaryScale>() // .Queryable // .Where(r => r.TitleCode == proposedTitle) // .FirstOrDefault(); salaryScale = SalaryScale.GetEffectiveSalaryScale(repository, proposedTitle, DateTime.Today); viewModel.SalaryReviewAnalysis.Title = viewModel.ProposedTitle; } else { // Else this is a standard equity review. titleCode = viewModel.SelectedEmployee.TitleCode; //salaryScale = repository.OfType<SalaryScale>() // .Queryable // .Where(r => r.TitleCode == viewModel.SelectedEmployee.TitleCode) // .FirstOrDefault(); salaryScale = SalaryScale.GetEffectiveSalaryScale(repository, viewModel.SelectedEmployee.TitleCode, DateTime.Today); viewModel.SalaryReviewAnalysis.Title = viewModel.SelectedEmployee.Title; } } else if (!String.IsNullOrEmpty(referenceNumber)) { // Reference number is present so try getting existing review by reference number: viewModel.SalaryReviewAnalysis = repository.OfType<SalaryReviewAnalysis>() .Queryable .Where(x => x.ReferenceNumber.Equals(referenceNumber)) .FirstOrDefault(); if (viewModel.SalaryReviewAnalysis != null) { titleCode = viewModel.SalaryReviewAnalysis.SalaryScale.TitleCode; viewModel.SraEmployee = viewModel.SalaryReviewAnalysis.Employee; viewModel.ProposedTitle = (viewModel.SalaryReviewAnalysis.IsReclass ? viewModel.SalaryReviewAnalysis.Title : null); salaryScale = SalaryScale.GetEffectiveSalaryScale(repository, viewModel.SalaryReviewAnalysis.SalaryScale.TitleCode, viewModel.SalaryReviewAnalysis.SalaryScale.EffectiveDate); } } if (salaryScale != null) { // Determine the user's school(s) var schoolsForUser = user.Units.Select(x => x.DeansOfficeSchoolCode).Distinct().ToArray(); // and populate the corresponding college averages: salaryScaleViewModel.CollegeAverages = repository.OfType<CollegeAverage>().Queryable.Where(x => schoolsForUser.Contains(x.SchoolCode) && x.TitleCode == titleCode). ToList(); var employeesSchoolCode = viewModel.SraEmployee.HomeDepartment.SchoolCode; var collegeAverage = salaryScaleViewModel.CollegeAverages.Where(x => x.SchoolCode.Equals(employeesSchoolCode)).Select(x => x.CollegeAverageAnnual). FirstOrDefault(); viewModel.CriteriaList = SalaryReviewAnalysis.GetCriteriaList(repository, salaryScale, collegeAverage); salaryScaleViewModel.SalaryScale = salaryScale; } } viewModel.SalaryScaleViewModel = salaryScaleViewModel; return viewModel; }
public ActionResult Edit(int id, SalaryScale salaryScale) { var salaryScaleToEdit = _salaryScaleRepository.GetNullableById(id); if (salaryScaleToEdit == null) return RedirectToAction("Index"); TransferValues(salaryScale, salaryScaleToEdit); if (ModelState.IsValid) { _salaryScaleRepository.EnsurePersistent(salaryScaleToEdit); Message = "SalaryScale Edited Successfully"; return RedirectToAction("Index"); } else { var viewModel = SalaryScaleViewModel.Create(Repository); viewModel.SalaryScale = salaryScale; return View(viewModel); } }