Esempio n. 1
0
        public async Task <IActionResult> Index()
        {
            try
            {
                IEnumerable <LeaveRequest> leaveRequests = (await leaveRequestService.GetLeaveRequests()).Select(lvlRequst =>
                {
                    lvlRequst.LeveRequestEncryptedId = protector.Protect(lvlRequst.Id.ToString());
                    return(lvlRequst);
                });

                var leaveTypes = await leaveTypeService.GetLeaveTypes();

                var employees = await employeeService.GetEmployees();

                LeaveRequestListViewModel model = new LeaveRequestListViewModel
                {
                    Employees     = employees,
                    LeaveTypes    = leaveTypes,
                    LeaveRequests = leaveRequests
                };
                return(View(model));
            }
            catch (Exception ex)
            {
                ViewBag.ErrorTitle   = "Resource not available:";
                ViewBag.ErrorMessage = ex.Message;
                return(View("CustomError"));
            }
        }
Esempio n. 2
0
 public async Task <GetLeaveRequestsResponse> GetLeaveRequests(string requestorEmail)
 {
     try
     {
         return(new GetLeaveRequestsResponse()
         {
             Success = true,
             Requests = await _leaveReqService.GetLeaveRequests(requestorEmail)
         });
     }
     catch (Exception e)
     {
         return(new GetLeaveRequestsResponse()
         {
             Success = false,
             ErrorMessage = e.Message
         });
     }
 }