public List <EpafDto> GetEpafByDocType(Enums.DocumentType docType) { var data = _epafService.GetEpafByDocumentType(docType); var retData = Mapper.Map <List <EpafDto> >(data); return(retData); }
public List <EpafDto> GetCrfEpaf(bool isActive = true) { var data = _epafService.GetEpafByDocumentType(Enums.DocumentType.CRF); var dataEpaf = Mapper.Map <List <EpafDto> >(data); var dataCrf = GetList(); var dataJoin = (from ep in dataEpaf join crf in dataCrf on ep.MstEpafId equals crf.EPAF_ID select new EpafDto() { CrfNumber = crf.DOCUMENT_NUMBER, MstEpafId = ep.MstEpafId, CrfStatus = Utils.EnumHelper.GetDescription((Enums.DocumentStatus)crf.DOCUMENT_STATUS), EmployeeId = crf.EMPLOYEE_ID, EmployeeName = crf.EMPLOYEE_NAME, CityNew = ep.City, BaseTownNew = ep.BaseTown, BaseTown = crf.LOCATION_OFFICE, City = crf.LOCATION_CITY, CrfId = crf.TRA_CRF_ID }).ToList(); var dataEmployee = _employeeService.GetEmployee(); foreach (var dtEp in dataEpaf) { var dataCrfJoin = dataJoin.Where(x => x.MstEpafId == dtEp.MstEpafId).FirstOrDefault(); if (dataCrfJoin != null) { dtEp.CrfId = dataCrfJoin.CrfId; dtEp.CrfNumber = dataCrfJoin.CrfNumber; dtEp.CrfStatus = dataCrfJoin.CrfStatus; dtEp.BaseTownNew = dataCrfJoin.BaseTownNew; dtEp.CityNew = dataCrfJoin.CityNew; dtEp.City = dataCrfJoin.City; dtEp.BaseTown = dataCrfJoin.BaseTown; } else { var employee = dataEmployee.Where(x => x.EMPLOYEE_ID == dtEp.EmployeeId).FirstOrDefault(); var baseTownNew = dtEp.BaseTown; var cityNew = dtEp.City; dtEp.BaseTown = employee.BASETOWN; dtEp.City = employee.CITY; dtEp.BaseTownNew = baseTownNew; dtEp.CityNew = cityNew; } } return(dataEpaf); }