private async Task AddCompanyVendorsMethod(CompanyVendors companyVendorsDTO) { var company = await _unitOfWork.CompanyRepository.GetByIdAsync(companyVendorsDTO.Id); if (company != null) { foreach (var companyDtoVendor in companyVendorsDTO.Vendors) { var vendor = await _unitOfWork.VendorRepository.GetByIdAsync(companyDtoVendor.Id); if (vendor != null) { company.Vendors.Add(vendor); } } await _unitOfWork.SaveAsync(); } }
private async Task <CompanyVendors> GetCompanyVendorsMethod(long id) { var company = await _unitOfWork.CompanyRepository.GetByIdAsync(id); var allVendors = await _unitOfWork.VendorRepository.GetAllAsync(); var reviews = await _unitOfWork.ReviewRepository.GetAllAsync(); if (company != null) { var companyVendors = new CompanyVendors { Id = company.Id, Vendors = CreateCompanyVendor(company.Vendors?.Where(v => v.Company.Id == company.Id), reviews, company), AllVendors = CreateCompanyVendor(allVendors.Where(x => x.Company == null && x.Company?.Id != company.Id), reviews, company) }; return(companyVendors); } return(null); }
public async Task AddCompanyVendors([FromBody] CompanyVendors companyVendors) { await _companyService.AddCompanyVendors(companyVendors); }
public async Task AddCompanyVendors(CompanyVendors companyVendorsDTO) { await AddCompanyVendorsMethod(companyVendorsDTO); }