// // GET: /ShowLeaveRequests/UserLeaveRequests public ActionResult UserLeaveRequests() { GetDescriptionController descr = new GetDescriptionController(); ViewBag.descr = descr; LeaveRequestsController userleaverequests = new LeaveRequestsController(); var requests = userleaverequests.GetUserLeaveRequests(WebSecurity.GetUserId(User.Identity.Name)); var acceptedRequests = userleaverequests.GetUserLeaveRequests(WebSecurity.GetUserId(User.Identity.Name), "A"); int numOfDaysAcquired = 0; foreach (var anAcceptedRequest in acceptedRequests) { numOfDaysAcquired += anAcceptedRequest.AcceptedNumOfDays; } ViewBag.numOfDaysAcquired = numOfDaysAcquired; CalcEligibleLeaveDaysController eligibleleavedays = new CalcEligibleLeaveDaysController(); int numOfEligibleDays = eligibleleavedays.Get(DateTime.Now); ViewBag.numOfEligibleDays = numOfEligibleDays; return(View(requests)); }
// GET api/CalcRemainingLeaveDays/5 public int Get(int id, int year = 0) { if (year < 2004) { year = DateTime.Now.Year; } LeaveRequestsController userleaverequests = new LeaveRequestsController(); var acceptedRequests = userleaverequests.GetUserLeaveRequests(id, "A", year); int numOfDaysAcquired = 0; foreach (var anAcceptedRequest in acceptedRequests) { numOfDaysAcquired += anAcceptedRequest.AcceptedNumOfDays; } CalcEligibleLeaveDaysController eligibleleavedays = new CalcEligibleLeaveDaysController(); int numOfEligibleDays = eligibleleavedays.Get(DateTime.Now); var numOfRemainingDays = numOfEligibleDays - numOfDaysAcquired; return(numOfRemainingDays); }