private void CheckAndMovePrincipalAddress(CompanyAddressForCreation companyAddress) { // TODO remove below and AutoMapp instead of var companyAddressEntity = new CompanyAddress { CompanyId = companyAddress.CompanyId, Address = companyAddress.Address, ZipCode = companyAddress.ZipCode, City = companyAddress.City, Country = companyAddress.Country, CompanyAdressTypeId = companyAddress.CompanyAdressTypeId }; CheckAndMovePrincipalAddress(companyAddressEntity); }
public async Task <bool> AddAddress(CompanyAddressForCreation companyAddressdto) { if (!await CompanyExists(companyAddressdto.CompanyId)) { return(false); } CheckAndMovePrincipalAddress(companyAddressdto); var company = await _repository.Get(companyAddressdto.CompanyId); // TODO AutoMapping company.CompanyAddresses.Add(new CompanyAddress { Address = companyAddressdto.Address, City = companyAddressdto.City, ZipCode = companyAddressdto.ZipCode, Country = companyAddressdto.Country, CompanyAdressTypeId = companyAddressdto.CompanyAdressTypeId, }); return(await _repository.Save()); }
public async Task <ActionResult <CompanyAddressForCreation> > AddAddress(int companyId, CompanyAddressForCreation companyAddress) { if (!await _companyService.CompanyExists(companyId)) { return(NotFound()); } if (!ModelState.IsValid) { return(BadRequest()); } companyAddress.CompanyId = companyId; if (!await _companyService.AddAddress(companyAddress)) { return(StatusCode(500, "A Problem happened while handling your request")); } return(Ok()); }
public Task <bool> AddAddress(CompanyAddressForCreation companyAddress) { throw new NotImplementedException(); }