Example #1
0
        /// <summary>
        /// Method to return the list of leave reports
        /// </summary>
        /// <param name="distinctLeaveRequests">list of LeaveRequest</param>
        /// <returns>List of leave reports</returns>
        private async Task <List <LeaveReport> > GetLeaveReportListAsync(List <LeaveRequest> distinctLeaveRequests)
        {
            List <LeaveReport> leaveReports = new List <LeaveReport>();

            foreach (var leaveRequest in distinctLeaveRequests)
            {
                //Get details of the employee from oauth server
                User user = await GetEmployeeByIdAsync(leaveRequest.EmployeeId);

                if (!string.IsNullOrEmpty(user.Id))
                {
                    LeaveReport leaveReport = new LeaveReport
                    {
                        Role                = user.Role,
                        EmployeeId          = user.Id,
                        EmployeeUserName    = user.Email,
                        EmployeeName        = string.Format(_stringConstant.EmployeeFirstLastNameFormat, user.FirstName, user.LastName),
                        TotalCasualLeave    = user.NumberOfCasualLeave,
                        TotalSickLeave      = user.NumberOfSickLeave,
                        UtilisedCasualLeave = await GetUtilisedCasualLeavesByEmployeeAsync(leaveRequest.EmployeeId),
                        BalanceCasualLeave  = user.NumberOfCasualLeave - (await GetUtilisedCasualLeavesByEmployeeAsync(leaveRequest.EmployeeId)),
                        UtilisedSickLeave   = await GetUtilisedSickLeavesByEmployeeAsync(leaveRequest.EmployeeId),
                        BalanceSickLeave    = user.NumberOfSickLeave - (await GetUtilisedSickLeavesByEmployeeAsync(leaveRequest.EmployeeId)),
                    };
                    leaveReports.Add(leaveReport);
                }
            }
            return(leaveReports);
        }
        /// <summary>
        /// Method to returns the list of leave reports
        /// </summary>
        /// <param name="distinctLeaveRequests"></param>
        /// <param name="accessToken"></param>
        /// <returns>List of leave reports</returns>
        private async Task <List <LeaveReport> > GetLeaveReportList(List <LeaveRequest> distinctLeaveRequests, string accessToken)
        {
            List <LeaveReport> leaveReports = new List <LeaveReport>();

            foreach (var leaveRequest in distinctLeaveRequests)
            {
                User user = await GetEmployeeById(leaveRequest.EmployeeId, accessToken);

                if (user != null)
                {
                    LeaveReport leaveReport = new LeaveReport
                    {
                        Role                = user.Role,
                        EmployeeId          = user.Id,
                        EmployeeUserName    = user.Email,
                        EmployeeName        = string.Format("{0} {1}", user.FirstName, user.LastName),
                        TotalCasualLeave    = user.NumberOfCasualLeave,
                        TotalSickLeave      = user.NumberOfSickLeave,
                        UtilisedCasualLeave = GetUtilisedCasualLeavesByEmployee(leaveRequest.EmployeeId),
                        BalanceCasualLeave  = user.NumberOfCasualLeave - GetUtilisedCasualLeavesByEmployee(leaveRequest.EmployeeId),
                        //UtilisedSickLeave = null,
                        //BalanceSickLeave = null
                    };
                    leaveReports.Add(leaveReport);
                }
            }
            return(leaveReports);
        }
Example #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            LeaveReport leaveReport = Service.GetById(id);

            Service.Delete(leaveReport);
            return(RedirectToAction("Index"));
        }
Example #4
0
        public ActionResult Report(EmployeeLeaveReport leaveTaken)
        {
            LeaveReport report    = new LeaveReport();
            var         employees = LeaveTakens(leaveTaken);

            byte[] abytes = report.PrePareReport(employees, leaveTaken);
            return(File(abytes, "application/pdf"));
        }
Example #5
0
 public ActionResult Edit(LeaveReport leaveReport)
 {
     if (ModelState.IsValid)
     {
         Service.Update(leaveReport);
         return(RedirectToAction("Index"));
     }
     return(View(leaveReport));
 }
Example #6
0
        // GET: LeaveReports/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LeaveReport leaveReport = Service.GetById(id.GetValueOrDefault());

            if (leaveReport == null)
            {
                return(HttpNotFound());
            }
            return(View(leaveReport));
        }
Example #7
0
        private void button4_Click(object sender, EventArgs e)
        {
            LeaveReport obj = new LeaveReport();

            obj.Show();
        }
 private void button4_Click(object sender, EventArgs e)
 {
     LeaveReport obj = new LeaveReport();
     obj.Show();
 }