Beispiel #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));
            }
        }
Beispiel #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));
        }
Beispiel #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));
        }
Beispiel #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));
        }
Beispiel #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));
            }
        }
Beispiel #6
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));
        }
Beispiel #7
0
        //
        // GET: /SalaryScale/Create
        public ActionResult Create()
        {
            var viewModel = SalaryScaleViewModel.Create(Repository);

            return(View(viewModel));
        }