예제 #1
0
        public IActionResult SupervisorReviewTimesheet(SupervisorTimeSheetViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (model.Approved == ApprovalType.Denied)
                {
                    if (model.DenialReason != null)
                    {
                        var timesheet = _context.TimeSheets.Find(model.TimesheetId);
                        timesheet.Approved     = model.Approved;
                        timesheet.ReasonDenied = model.DenialReason;
                        _context.TimeSheets.Update(timesheet);
                        _context.SaveChanges();
                    }
                    else
                    {
                        //Denial Reason is mandatory if the TimeSheet is denied
                        return(View(model));
                    }
                }
                else
                {
                    var timesheet = _context.TimeSheets.Find(model.TimesheetId);
                    timesheet.Approved = model.Approved;
                    _context.TimeSheets.Update(timesheet);
                    _context.SaveChanges();
                    return(View("Index"));
                }
            }


            return(RedirectToAction("SupervisorsPendingTimeSheets"));
        }
예제 #2
0
        public IActionResult SupervisorReviewTimesheet(int id)
        {
            var supervisor    = _userManager.FindByNameAsync(User.Identity.Name).Result;
            var timesheet     = _context.TimeSheets.Find(id);
            var timesheetUser = _userManager.FindByIdAsync(timesheet.UserId).Result;
            var timeWorked    = TimeSheetTimeSpent(timesheet);
            var amountMade    = TimeSheetAmountMade(timesheet, timeWorked);


            var model = new SupervisorTimeSheetViewModel
            {
                StartDate    = timesheet.StartDate,
                EndDate      = timesheet.EndDate,
                Exempt       = timesheet.ExemptFromOvertime,
                Approved     = timesheet.Approved,
                TotalEarning = amountMade,
                TotalHours   = timeWorked,
                DenialReason = timesheet.ReasonDenied ?? "Not Denied Yet",
                TimesheetId  = timesheet.Id,
                User         = timesheetUser.Email
            };


            return(View(model));
        }