public async Task <JobCommercialUnitDto> GetJobUnitById(IdInputExtensionDto <bool, int> input) { if (input.Value) { var jobitem = await _jobUnitRepository.GetAsync(input.Id); //Mapper.CreateMap<JobUnit, JobCommercialUnitDto>() // .ForMember(u => u.JobId, ap => ap.MapFrom(src => src.Id)); var config = new MapperConfiguration(cfg => { cfg.CreateMap <JobUnit, JobCommercialUnitDto>().ForMember(u => u.JobId, ap => ap.MapFrom(src => src.Id)); }); JobCommercialUnitDto result = new JobCommercialUnitDto(); Mapper.Map(jobitem, result); return(result); } else { var jobitem = await _jobDetailUnitRepository.GetAsync(input.Id); JobCommercialUnitDto result = jobitem.MapTo <JobCommercialUnitDto>(); result.JobId = jobitem.Id; return(result); } }
public async Task <PagedResultOutput <JobCommercialUnitDto> > GetJobUnits(SearchInputDto input) { var query = from job in _jobDetailUnitRepository.GetAll() join emp in _employeeUnitRepository.GetAll() on job.DirectorEmployeeId equals emp.Id into employee from em in employee.DefaultIfEmpty() join cust in _customerUnitRepository.GetAll() on job.AgencyId equals cust.Id into tempcust from cs in tempcust.DefaultIfEmpty() select new { Job = job, DirectorName = em.LastName, Agency = cs.LastName }; if (!ReferenceEquals(input.Filters, null)) { SearchTypes mapSearchFilters = Helper.MappingFilters(input.Filters); query = Helper.CreateFilters(query, mapSearchFilters); } query = query.Where(item => item.Job.IsDivision == false); var resultCount = await query.CountAsync(); var results = await query .AsNoTracking() .OrderBy(Helper.GetSort("Job.JobNumber ASC", input.Sorting)) .PageBy(input) .ToListAsync(); return(new PagedResultOutput <JobCommercialUnitDto>(resultCount, results.Select(item => { var dto = new JobCommercialUnitDto() { JobId = item.Job.Id, BidDate = item.Job.BidDate, AwardDate = item.Job.AwardDate, ShootingDate = item.Job.ShootingDate, WrapDate = item.Job.WrapDate, RoughCutDate = item.Job.RoughCutDate, AirDate = item.Job.AirDate, DateClosed = item.Job.DateClosed, FinalShootDate = item.Job.FinalShootDate, ProductOwner = item.Job.ProductOwner, ProductName = item.Job.ProductName, ExecutiveProducerId = item.Job.ExecutiveProducerId, DirectorEmployeeId = item.Job.DirectorEmployeeId, ProducerEmployeeId = item.Job.ProducerEmployeeId, SetDesignerEmployeeId = item.Job.SetDesignerEmployeeId, EditorEmployeeId = item.Job.EditorEmployeeId, ArtDirectorEmployeeId = item.Job.ArtDirectorEmployeeId, SalesRepId = item.Job.SalesRepId, AgencyId = item.Job.AgencyId, AgencyClientCustomerId = item.Job.AgencyClientCustomerId, ThirdPartyCustomerId = item.Job.ThirdPartyCustomerId, AgencyProducer = item.Job.AgencyProducer, AgencyProducerContactInfo = item.Job.AgencyProducerContactInfo, AgencyArtDirector = item.Job.AgencyArtDirector, AgencyArtDirContactInfo = item.Job.AgencyArtDirContactInfo, AgencyWriter = item.Job.AgencyWriter, AgencyBusinessManager = item.Job.AgencyBusinessManager, AgencyBusMgrContactInfo = item.Job.AgencyBusMgrContactInfo, AgencyJobNumber = item.Job.AgencyJobNumber, AgencyPONumber = item.Job.AgencyPONumber, AgencyName = item.Job.AgencyName, AgencyAddress = item.Job.AgencyAddress, AgencyPhone = item.Job.AgencyPhone, CommercialTitle1 = item.Job.CommercialTitle1, CommercialTitle2 = item.Job.CommercialTitle2, CommercialTitle3 = item.Job.CommercialTitle3, JobNumber = item.Job.JobNumber, Caption = item.Job.Caption, RollupCenterId = item.Job.RollupCenterId, IsCorporateDefault = item.Job.IsCorporateDefault, ChartOfAccountId = item.Job.ChartOfAccountId, RollupAccountId = item.Job.RollupAccountId, TypeOfCurrencyId = item.Job.TypeOfCurrencyId, RollupJobId = item.Job.RollupJobId, TypeOfJobStatusId = item.Job.TypeOfJobStatusId, TypeOfBidSoftwareId = item.Job.TypeOfBidSoftwareId, IsActive = item.Job.IsActive, IsApproved = item.Job.IsApproved, IsICTDivision = item.Job.IsICTDivision, TypeofProjectId = item.Job.TypeofProjectId, TaxRecoveryId = item.Job.TaxRecoveryId }; if (item.DirectorName != null) { dto.DirectorName = item.DirectorName; } if (item.Agency != null) { dto.Agency = item.Agency; } dto.JobStatusName = item.Job.TypeOfJobStatusId != null ? item.Job.TypeOfJobStatusId.ToDisplayName() : ""; dto.TypeofProjectName = item.Job.TypeofProjectId != null ? item.Job.TypeofProjectId.ToDisplayName() : ""; return dto; }).ToList())); }