public async Task AddAsync_Should_AddData_And_MakeItAvailable_When_ManualSaveWasRun() { var newExample = new Example { Id = Guid.NewGuid(), Name = "test1" }; await _exampleRepository.AddAsync(newExample); await _context.SaveChangesAsync(); _context.Examples.Count().Should().Be(1); _context.Examples.Should().Contain(newExample); }
public async Task <ExampleResponse> HandleAsync(CreateExampleRequst request) { var example = new Example { Data1 = request.Data1, Data2 = request.Data2 }; var returnExample = await _repository.AddAsync(example); return(returnExample.ToResponse()); }
public async Task <ActionResult> Post([FromBody] Example example) { try { await exampleRepository.AddAsync(example); return(Ok()); } catch (Exception exception) { logger.LogError(exception, "Failed to create Example"); return(StatusCode(StatusCodes.Status500InternalServerError, "Failed to retrieve examples")); } }
public async Task <Example> Handle(CreateExampleCommand request, CancellationToken cancellationToken) { var newExample = _mapper.Map <Example>(request); if (!IsValid(newExample)) { return(null); } await _exampleRepository.AddAsync(newExample); await Commit(); return(newExample); }
public async Task <IResult> AddAsync(Example example) { await _exampleRepository.AddAsync(example); return(new SuccessResult($"{example.Title} başlıklı Örnek Veri Başarıyla Eklenmiştir.")); }