Esempio n. 1
0
        public async Task <CompanyAddressDto> UpdateAddress(long companyId, CompanyAddressDto dto)
        {
            var entity = await _companyAddressManager.Find(dto.Id);

            if (entity == null)
            {
                entity = await _companyAddressManager.Create(_mapper.Map <CompanyAddressEntity>(dto));

                var company = await _companyManager.Find(companyId);

                company.AddressId = entity.Id;
                await _companyManager.Update(company);
            }
            else
            {
                var updateEntity = _mapper.Map(dto, entity);
                entity = await _companyAddressManager.Update(updateEntity);
            }

            return(_mapper.Map <CompanyAddressDto>(entity));
        }
Esempio n. 2
0
        public async Task <CompanyAddress> Put(int id, [FromBody] CompanyAddress value)
        {
            await _companyAddressManager.Update(id, value);

            return(await _companyAddressManager.Read(id));
        }