Example #1
0
        public async Task AddPhoneBook_Should_AddNewRecord()
        {
            var newRecord = new PhoneBookRecord("new record", "with phonenumber");

            _phonebookRepository.Add(newRecord);

            await _unitOfWork.CommitAsync();

            var addedRecord = await _phonebookRepository.GetAsync(newRecord.Id);

            Assert.Equal("with phonenumber", addedRecord.PhoneNumber);
        }
Example #2
0
        public override async Task <ActionResult <PhoneBookRecord> > HandleAsync(
            [FromBody] AddPhoneBookrecordRequest request,
            CancellationToken cancellationToken = default)
        {
            // var record = _mapper.Map<PhoneBookRecord>(request);
            PhoneBookRecord record = new() { Name = request.Name, PhoneNumber = request.PhoneNumber };

            _repository.Add(record);
            record.UpdateTags(request.TagIds);

            await _unitOfWork.CommitAsync(cancellationToken);

            return(Ok(record));
        }
    }