示例#1
0
        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));
            }
        }
示例#2
0
        // GET: /SalaryScale/_SalaryScale?TitleCode=4001, , (EffectiveDate=09-20-2011 optional; otherwise, uses today's date.)
        public ActionResult _SalaryScale(string titleCode, string effectiveDate)
        {
            //ICriteria criteria = NHibernateSessionManager.Instance.GetSession().CreateCriteria(TypeOf(SalaryScale))
            //    .SetFetchMode("SalarySteps", FetchMode.Eager);

            var user             = Esra.Core.Domain.User.GetByLoginId(Repository, User.Identity.Name);
            var salaryScaleModel = SalaryScaleViewModel.Create(Repository, titleCode, effectiveDate, user);

            // Example 1
            //var salaryScale = _salaryScaleRepository.Queryable
            //    .Where(r => r.TitleCode == titleCode)
            //    .FirstOrDefault();

            //var salaryScale = SalaryScale.GetEffectiveSalaryScale(Repository, titleCode, DateTime.Now);

            // Example 2
            //var salaryScale = Repository.OfType<SalaryScale>()
            //    .Queryable
            //    .Where(r => r.TitleCode == titleCode)
            //    .FirstOrDefault();

            //if (salaryScale != null)
            //{
            //    salaryScale.SalarySteps = Repository.OfType<SalaryStep>()
            //        .Queryable
            //        .Where(s => s.TitleCode == salaryScale.TitleCode && s.EffectiveDate == salaryScale.EffectiveDate)
            //        .OrderBy(x => x.Annual)
            //        .ToList();

            //    salaryScaleModel.SalaryScale = salaryScale;
            //}

            // Other examples:
            // Note that this is now handled in the model directly.
            //var titles = Repository.OfType<Title>()
            //                      .Queryable
            //                      .Select(t => new { t.TitleCode, t.PayrollTitle })
            //                      .OrderBy(t => t.PayrollTitle)
            //                      .ToList() as IDictionary<string, string>;

            //salaryScaleModel.Titles = Repository.OfType<Title>()
            //                      .Queryable

            //                      .OrderBy(t => t.PayrollTitle)
            //                      .ToList();

            //salaryScaleModel.TitleCodes = Repository.OfType<Title>()
            //           .Queryable

            //           .OrderBy(t => t.TitleCode)
            //           .ToList();

            return(PartialView(salaryScaleModel));
        }
示例#3
0
        //
        // GET: /SalaryScale/Edit/5
        public ActionResult Edit(int id)
        {
            var salaryScale = _salaryScaleRepository.GetNullableById(id);

            if (salaryScale == null)
            {
                return(RedirectToAction("Index"));
            }

            var viewModel = SalaryScaleViewModel.Create(Repository);

            viewModel.SalaryScale = salaryScale;

            return(View(viewModel));
        }
示例#4
0
        //
        // GET: /SalaryScale/
        public ActionResult Index()
        {
            var salaryScaleModel = SalaryScaleViewModel.Create(Repository);

            // Example:
            // Note that setting salaryScaleModel.Titles is now handled directly in the model
            //salaryScaleModel.Titles = Repository.OfType<Title>()
            //                      .Queryable
            //                      .OrderBy(t => t.AbbreviatedName)
            //    // .ThenBy(t => t.TitleCode)
            //                      .ToList();

            //salaryScaleModel.TitleCodes = salaryScaleModel.Titles
            //    .OrderBy(t => t.TitleCode)
            //    .ToList();

            return(View(salaryScaleModel));
        }
示例#5
0
        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));
            }
        }
        /// <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;
        }
示例#7
0
        // Example
        // GET: /SalaryScale/Details/5
        //public ActionResult SalaryScaleDetails(int id)
        //{
        //    var salaryScale = _salaryScaleRepository.GetNullableById(id);

        //    if (salaryScale == null) return RedirectToAction("Index");

        //    return View(salaryScale);
        //}

        //
        // GET: /SalaryScale/Details?TitleCode=4001, (EffectiveDate=09-20-2011 optional; otherwise, uses today's date.)
        public ActionResult Details(string titleCode, string effectiveDate)
        {
            //ICriteria criteria = NHibernateSessionManager.Instance.GetSession().CreateCriteria(TypeOf(SalaryScale))
            //    .SetFetchMode("SalarySteps", FetchMode.Eager);

            //var searchDate = DateTime.Now;
            //DateTime.TryParse(effectiveDate,  out searchDate);

            // DateTime  searchDate = String.IsNullOrEmpty(effectiveDate) ? DateTime.Now : bool validDate = DateTime.TryParse(effectiveDate, out searchDate);

            var user             = Esra.Core.Domain.User.GetByLoginId(Repository, User.Identity.Name);
            var salaryScaleModel = SalaryScaleViewModel.Create(Repository, titleCode, effectiveDate, user);

            //salaryScaleModel.TitleCode = titleCode;

            // Example:
            // Note setting salaryScaleModel.Titles is now handled directly in the model
            //salaryScaleModel.Titles = Repository.OfType<Title>()
            //                      .Queryable
            //                      .OrderBy(t => t.AbbreviatedName)
            //    // .ThenBy(t => t.TitleCode)
            //                      .ToList();

            //salaryScaleModel.TitleCodes = salaryScaleModel.Titles
            //           .OrderBy(t => t.TitleCode)
            //           .ToList();

            // Example 1:
            //var salaryScale = _salaryScaleRepository.Queryable
            //    .Where(r => r.TitleCode == titleCode)
            //    .FirstOrDefault();

            // Example 2:
            //var salaryScale = Repository.OfType<SalaryScale>()
            //    .Queryable
            //    .Where(r => r.TitleCode == titleCode)
            //    .FirstOrDefault();)

            // Note that an "effectiveDate" is also required in order to fetch the salary scale in effect on the date provided.
            //var salaryScale = SalaryScale.GetEffectiveSalaryScale(Repository, titleCode, searchDate);
            //salaryScaleModel.SalaryScale = SalaryScale.GetEffectiveSalaryScale(Repository, titleCode, searchDate);

            //if (salaryScale != null)
            //{
            //    salaryScale.SalarySteps = Repository.OfType<SalaryStep>()
            //        .Queryable
            //        .Where(s => s.TitleCode == salaryScale.TitleCode && s.EffectiveDate == salaryScale.EffectiveDate)
            //        .OrderBy(x => x.Annual)
            //        .ToList();

            //    salaryScaleModel.SalaryScale = salaryScale;
            //}

            // Examples:
            //var titles = Repository.OfType<Title>()
            //                      .Queryable
            //                      .Select(t => new { t.TitleCode, t.PayrollTitle })
            //                      .OrderBy(t => t.PayrollTitle)
            //                      .ToList() as IDictionary<string, string>;

            //salaryScaleModel.Titles = Repository.OfType<Title>()
            //                      .Queryable

            //                      .OrderBy(t => t.PayrollTitle)
            //                      .ToList();

            //salaryScaleModel.TitleCodes = Repository.OfType<Title>()
            //           .Queryable

            //           .OrderBy(t => t.TitleCode)
            //           .ToList();

            //if (salaryScale == null) return RedirectToAction("Index");
            //if (salaryScale == null)
            //{
            //    return RedirectToAction("Index");
            //}
            return(View(salaryScaleModel));
        }
示例#8
0
        //
        // GET: /SalaryScale/Create
        public ActionResult Create()
        {
            var viewModel = SalaryScaleViewModel.Create(Repository);

            return(View(viewModel));
        }