Exemplo n.º 1
0
        public async Task <IActionResult> PostAsync([FromBody] SavePhoneBookDTO phonebook)
        {
            var phone  = _mapper.Map <SavePhoneBookDTO, PhoneBook>(phonebook);
            var result = await _phonebookService.SaveAsync(phone);

            if (!result.Success)
            {
                return(BadRequest(new ErrorDTO(result.Message)));
            }

            var phoneBookDTO = _mapper.Map <PhoneBook, PhoneBookDTO>(result.Resource);

            return(Ok(phoneBookDTO));
        }