public async Task <IActionResult> Delete([FromBody] RecordDo record) { if (record == null) { return(BadRequest(RecordShouldNotBeNull)); } return(await TryExecutingServiceAsync(() => _recordService.Delete(record), Ok())); }
public async Task Delete_ShouldCallUnitOfWorkDeleteAndSaveChanges() { CreateSubject(); var record = new RecordDo(); await _subject.Delete(record); await _unitOfWork.Received().SaveChangesAsync(); }
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))); }
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())); }
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); }
public async Task Delete(RecordDo record) { _unitOfWork.Records.Delete(record); await _unitOfWork.SaveChangesAsync(); }
public async Task Update(RecordDo record) { await _unitOfWork.Records.Update(record); await _unitOfWork.SaveChangesAsync(); }