public ActionResult <PhoneReadDto> CreatePhone(PhoneCreateDto phoneCreateDto) { var phone = _mapper.Map <Phone>(phoneCreateDto); _repository.CreatePhone(phone); _repository.SaveChanges(); var phoneReadDto = _mapper.Map <PhoneReadDto>(phone); return(NoContent()); //CreatedAtRoute(nameof(GetPhoneById), new { Id = phoneReadDto.Id }, phoneReadDto); }
public async Task <IActionResult> CustomerAddPhone(int id, PhoneCreateDto phoneCreateDto) { var phoneToCreate = _mapper.Map <Phone>(phoneCreateDto); var customerPhoneExist = await _customersRepo.CustomerPhoneExists(id, phoneToCreate); if (customerPhoneExist) { return(BadRequest("This phone number already exists in you account.")); } await _customersRepo.CustomerAddPhone(id, phoneToCreate); return(StatusCode(201)); }