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);
        }
Ejemplo n.º 2
0
        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());
        }
Ejemplo n.º 3
0
        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"));
            }
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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."));
        }