예제 #1
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"));
        }
예제 #2
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"));
        }