Exemplo n.º 1
0
        public async Task CreateFooType(FooTypeDto item)
        {
            var entity = _mapper.Map <FooTypeEntity>(item);

            _context.FooTypes.Add(entity);
            await _context.SaveChangesAsync();
        }
Exemplo n.º 2
0
        public async Task CreateFooType(FooTypeDto item)
        {
            var query = "INSERT INTO [dbo].[FooTypes] ([FooTypeId], [Name], [Active]) VALUES (@FooTypeId, @Name, @Active);";

            using (var connection = new SqlConnection(_connectionString))
            {
                await connection.ExecuteAsync(query, new { FooTypeId = item.FooTypeId, Name = item.Name, Active = item.Active });
            }
        }
Exemplo n.º 3
0
        public async Task CreateFooType(FooTypeDto item)
        {
            var doc = _mapper.Map <FooTypeDoc>(item);

            using (var session = await _client.StartSessionAsync())
            {
                await _collection.InsertOneAsync(session, doc);
            }
        }
Exemplo n.º 4
0
        public async Task Manager_Should_Create_FooType()
        {
            var context = FooGooTestHelpers.GetDummyContext();
            var manager = FooGooTestHelpers.GetFooManager(context);

            var item = new FooTypeDto {
                FooTypeId = Guid.NewGuid(), Name = Guid.NewGuid().ToString(), Active = true
            };
            await manager.CreateFooType(item);

            var result = await manager.GetFooType(item.FooTypeId);

            Assert.Equal(item.Name, result.Name);
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Create([FromBody] FooTypeDto item)
        {
            await _manager.CreateFooType(item);

            return(Ok());
        }