Ejemplo n.º 1
0
        public async Task <ServiceResponse <AddPhoneBookEntryResponse> > AddEntry(AddPhoneBookEntryRequest phoneBookEntry, Guid userId)
        {
            var bookEntryRecord = phoneBookEntry.MapGeneric <EntryEntity, AddPhoneBookEntryRequest>();

            bookEntryRecord.PhoneBookId = userId;

            if (await _phoneBookRepository.ExistAsync(phoneBookEntry.Name))
            {
                throw new BadRequestException("Entry already exist");
            }

            await _phoneBookRepository.SaveAsync(bookEntryRecord);

            return(new ServiceResponse <AddPhoneBookEntryResponse>("Successfully added an entry")
            {
                Data = new AddPhoneBookEntryResponse
                {
                    IsAdded = true
                }
            });
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> AddEntry(AddPhoneBookEntryRequest addPhoneBookEntryRequest)
        {
            var response = await _phoneBookService.AddEntry(addPhoneBookEntryRequest, GetUserToken().UserId);

            return(Created(string.Empty, response));
        }