Exemplo n.º 1
0
        /// <summary>
        /// To get list of Leave Request depend upon leave type of a particular employee
        /// </summary>
        /// <param name="type"></param>
        /// <param name="employeeId"></param>
        /// <returns></returns>
        public IEnumerable <LeaveRequestAC> LeaveRequestByType(LMS.DomainModel.Models.Type type, string employeeId)
        {
            var leaveRequestList   = _leaveRequestDataRepository.Fetch(x => x.Type == type && x.EmployeeId == employeeId);
            var leaveRequestListAC = new List <LeaveRequestAC>();

            foreach (var leaves in leaveRequestList)
            {
                var leaveStatus = _leaveStatusDataRepository.Fetch(x => x.LeaveRequestId == leaves.Id);
                var employee    = _employeeDataRepository.GetById(leaves.EmployeeId);
                var leaveAC     = new LeaveRequestAC
                {
                    Id                  = leaves.Id,
                    StartDate           = leaves.StartDate,
                    EndDate             = leaves.EndDate,
                    Unit                = leaves.Unit,
                    Reason              = leaves.Reason,
                    Type                = leaves.Type,
                    HolidayName         = leaves.HolidayName,
                    CompensationDate    = leaves.CompensationDate,
                    CompensationStatus  = leaves.CompensationStatus,
                    ContactName         = leaves.ContactName,
                    EmergencyContact    = leaves.ContactNumber,
                    PointOfContact      = leaves.PointOfContact,
                    DoctorName          = leaves.DoctorName,
                    DoctorContactNumber = leaves.Number,
                    DoctorCertificate   = leaves.Certificate,
                    HolidayTypeId       = leaves.HolidayTypeId,
                    EmployeeId          = leaves.EmployeeId,
                    Condition           = ((DomainModel.Models.Condition)leaves.Condition),
                    EmployeeName        = employee.Name
                };
                List <Condition> conditionList     = new List <Condition>();
                List <string>    teamLeaderList    = new List <string>();
                List <string>    requestReasonList = new List <string>();
                foreach (var leave in leaveStatus)
                {
                    List <string> list      = new List <string>();
                    var           employees = _employeeDataRepository.FirstOrDefault(x => x.Id == leave.TeamLeaderId);
                    teamLeaderList.Add(employees.Name);
                    requestReasonList.Add(leave.StatusReason);
                    conditionList.Add(leave.Condition);
                }
                leaveAC.TeamLeader    = teamLeaderList;
                leaveAC.ResultReason  = requestReasonList;
                leaveAC.ConditionList = conditionList;
                leaveRequestListAC.Add(leaveAC);
            }
            return(leaveRequestListAC);
        }
Exemplo n.º 2
0
        public IHttpActionResult LeaveRequestByType(LMS.DomainModel.Models.Type leaveType)
        {
            var employeeId = User.Identity.GetUserId();

            if (employeeId == null)
            {
                return(NotFound());
            }
            try
            {
                var leavesDetails = _leaveReviewRepository.LeaveRequestByType(leaveType, employeeId);
                return(Ok(leavesDetails));
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }