Exemplo n.º 1
0
        //
        // GET: /SalaryReviewAnalysis/
        public ActionResult Index(string selectedReferenceNumber, string selectedEmployee, int?selectedUser, string creationDateString)
        {
            var salaryReviewAnalysisSearchParamsModel = new SalaryReviewAnalysisSearchParamsModel
            {
                SelectedReferenceNumber = selectedReferenceNumber,
                SelectedEmployeeId      = selectedEmployee,
                SelectedUserId          = selectedUser,
                CreationDateString      =
                    (String.IsNullOrEmpty(creationDateString)
                                                                         ? DateTime.Now.ToString("MM/dd/yyyy")
                                                                         : creationDateString)
            };
            var salaryReviewAnalysisModel = SalaryReviewAnalysisViewModel.Create(Repository, IsDepartmentUser, Esra.Core.Domain.User.GetByLoginId(Repository, CurrentUser.Identity.Name), salaryReviewAnalysisSearchParamsModel);

            return(View(salaryReviewAnalysisModel));
        }
Exemplo n.º 2
0
        public ActionResult Create(SalaryReviewAnalysis salaryReviewAnalysis)
        {
            var salaryReviewAnalysisToCreate = new SalaryReviewAnalysis();

            TransferValues(salaryReviewAnalysis, salaryReviewAnalysisToCreate);

            if (ModelState.IsValid)
            {
                _salaryReviewAnalysisRepository.EnsurePersistent(salaryReviewAnalysisToCreate);

                Message = "SalaryReviewAnalysis Created Successfully";

                return(RedirectToAction("Index"));
            }
            else
            {
                var viewModel = SalaryReviewAnalysisViewModel.Create(Repository);
                viewModel.SalaryReviewAnalysis = salaryReviewAnalysis;

                return(View(viewModel));
            }
        }
Exemplo n.º 3
0
        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));
            }
        }