Esempio n. 1
0
        public void Update(int id, UpdateOperatorDto dto)
        {
            var operatorDb = _operatorRepository.FindById(id);

            if (operatorDb == null)
            {
                throw new Exception("Operator was not found");
            }

            if (dto.Name != null)
            {
                operatorDb.Name = dto.Name;
            }

            if (dto.Email != null)
            {
                operatorDb.Email = dto.Email;
            }

            if (dto.Phone != null)
            {
                operatorDb.Phone = dto.Phone;
            }

            if (dto.Website != null)
            {
                operatorDb.Website = dto.Website;
            }

            if (dto.AddressId != operatorDb.Address.Id)
            {
                var address = _addressRepository.FindById(dto.AddressId);

                if (address != null)
                {
                    operatorDb.Address = address;
                }
            }

            _operatorRepository.Update(operatorDb);
        }
 public void Put(int id, [FromBody] UpdateOperatorDto dto)
 {
     _operatorService.Update(id, dto);
 }