예제 #1
0
        public async Task <IActionResult> Delete([FromBody] RecordDo record)
        {
            if (record == null)
            {
                return(BadRequest(RecordShouldNotBeNull));
            }

            return(await TryExecutingServiceAsync(() => _recordService.Delete(record), Ok()));
        }
예제 #2
0
        public async Task Delete_ShouldCallUnitOfWorkDeleteAndSaveChanges()
        {
            CreateSubject();
            var record = new RecordDo();

            await _subject.Delete(record);

            await _unitOfWork.Received().SaveChangesAsync();
        }
예제 #3
0
        public async Task <IActionResult> Create([FromBody] RecordDo record)
        {
            if (record == null)
            {
                return(BadRequest(RecordShouldNotBeNull));
            }

            return(await TryExecutingServiceAsync(() => _recordService.Create(record), CreatedAtRoute("GetRecordById", new { id = record.RecordId }, record)));
        }
예제 #4
0
        public async Task <IActionResult> Update(int id, [FromBody] RecordDo record)
        {
            if (record == null)
            {
                return(BadRequest(RecordShouldNotBeNull));
            }
            if (id == 0)
            {
                return(BadRequest(ValidRecordIdShouldBeProvided));
            }

            return(await TryExecutingServiceAsync(() => _recordService.Update(record), Ok()));
        }
예제 #5
0
        public async Task Create_ShouldAddRecordInDbContext()
        {
            var record = new RecordDo {
                Title = "Midnight Marauders", ReleaseYear = 1993
            };

            _subject.Create(record);
            _dbContext.SaveChanges();

            var result = (await _subject.GetAll()).ToList();

            result.Should().HaveCount(2);
            result.Last().Title.Should().Be(record.Title);
        }
예제 #6
0
 public async Task Delete(RecordDo record)
 {
     _unitOfWork.Records.Delete(record);
     await _unitOfWork.SaveChangesAsync();
 }
예제 #7
0
        public async Task Update(RecordDo record)
        {
            await _unitOfWork.Records.Update(record);

            await _unitOfWork.SaveChangesAsync();
        }