Пример #1
0
        public IActionResult OnPost(string submit)
        {
            if (submit == "Cancel")
            {
                return(RedirectToPage("Index"));
            }

            if (!ModelState.IsValid)
            {
                PayRoll = _payrollDm.PopulateSelectedList(PayRoll);
                return(Page());
            }

            if (_payrollDm.BlnFindPayRollByAuthorId(int.Parse(PayRoll.AuthorTypeId)))
            {
                ModelState.AddModelError("AuthorTypeId", "Author has an existing PayRoll record.");
            }
            else
            {
                ModelState.Clear();
            }

            if (!ModelState.IsValid)
            {
                PayRoll = _payrollDm.PopulateSelectedList(PayRoll);
                return(Page());
            }

            _payrollDm.Add(PayRoll);
            return(RedirectToPage("Index"));
        }
Пример #2
0
        public ActionResult Create(PayRollVM.Payroll payroll, string submit)
        {
            if (submit == "Cancel")
            {
                return(RedirectToAction("Index"));
            }

            if (!ModelState.IsValid)
            {
                return(View(pdm.PopulateSelectedList(payroll)));
            }

            if (pdm.BlnFindPayRollByAuthorId(int.Parse(payroll.AuthorTypeId)))
            {
                ModelState.AddModelError(string.Empty, "Author has an existing PayRoll record.");
            }

            if (!ModelState.IsValid)
            {
                return(View(pdm.PopulateSelectedList(payroll)));
            }

            pdm.Add(payroll);
            return(RedirectToAction("Index"));
        }
Пример #3
0
        public ActionResult Edit(PayRollVM.Payroll payroll, string submit)
        {
            if (submit == "Cancel")
            {
                return(RedirectToAction("Index"));
            }

            if (!ModelState.IsValid)
            {
                return(View(payroll));
            }

            pdm.Update(payroll);
            return(RedirectToAction("Index"));
        }
Пример #4
0
 public IActionResult OnGet(int id)
 {
     PayRoll = _payrollDm.Find(id);
     return(Page());
 }
Пример #5
0
 public IActionResult OnGet()
 {
     PayRoll = _payrollDm.Add();
     return(Page());
 }