예제 #1
0
        public async Task <IActionResult> EditPast(PastEmployment pastEmployment, int id)
        {
            PastEmployment pastEmployment1 = await _payrollDb.PastEmployments.FindAsync(id);

            if (ModelState.IsValid)
            {
                if (pastEmployment1 != null)
                {
                    pastEmployment1.Company             = pastEmployment.Company;
                    pastEmployment1.StartDate           = pastEmployment.StartDate;
                    pastEmployment1.EndDate             = pastEmployment.EndDate;
                    pastEmployment1.TheReasonForFailure = pastEmployment.Company;
                    pastEmployment1.EmployeeId          = pastEmployment.EmployeeId;

                    await _payrollDb.SaveChangesAsync();

                    return(RedirectToAction(nameof(ListPast)));
                }

                else
                {
                    return(Redirect("~/Account/Error"));
                }
            }
            else
            {
                return(View());
            }
        }
예제 #2
0
        public async Task <IActionResult> CreatePast(PastEmployment pastEmployment)
        {
            if (ModelState.IsValid)
            {
                PastEmployment p = pastEmployment;
                await _payrollDb.PastEmployments.AddAsync(p);

                await _payrollDb.SaveChangesAsync();

                return(RedirectToAction(nameof(ListPast)));
            }
            else
            {
                return(View());
            }
        }