public async Task CreateFooType(FooTypeDto item) { var entity = _mapper.Map <FooTypeEntity>(item); _context.FooTypes.Add(entity); await _context.SaveChangesAsync(); }
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 }); } }
public async Task CreateFooType(FooTypeDto item) { var doc = _mapper.Map <FooTypeDoc>(item); using (var session = await _client.StartSessionAsync()) { await _collection.InsertOneAsync(session, doc); } }
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); }
public async Task <IActionResult> Create([FromBody] FooTypeDto item) { await _manager.CreateFooType(item); return(Ok()); }