public TestMinimal MapToBLL(TestCreate apiTest) { return(new TestMinimal { Id = 0, TestTypeId = apiTest.TestTypeId, TestName = apiTest.TestName }); }
public async Task <ActionResult <Domain.App.Test> > PostTest(TestCreate test) { var bllEntity = _mapper.MapToBLL(test); _bll.Tests.AddNoReturn(bllEntity); await _bll.SaveChangesAsync(); return(CreatedAtAction("GetTest", new { id = bllEntity.Id }, test)); }
public void TestCreate_should_invoke_TestCreateHandler_handle() { // Arrange var create = new TestCreate(); // Act var result = MessageBusAccessor.Instance.Create <TestCreate, int>(create); // Assert VerifyMessageProcessing(typeof(TestCreateHandler), create.GetType()); result.Should().Be(TestCreateHandler.DefaultReturnValue); }
public int Create(TestCreate request) { using (var con = GetConnection()) { var cmd = con.CreateCommand(); cmd.CommandText = "Test_Insert"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@firstName", request.FirstName); cmd.Parameters.AddWithValue("@lastName", request.LastName); cmd.Parameters.Add("@Id", SqlDbType.Int).Direction = ParameterDirection.Output; cmd.ExecuteNonQuery(); //executeNonQuery means no rows will come back out return((int)cmd.Parameters["@Id"].Value); } }
public async Task <IActionResult> CreateTest([FromBody] TestCreate testToCreate) { if (testToCreate == null) { throw new ArgumentNullException(nameof(testToCreate)); } if (!Authorize(testToCreate)) { return(Unauthorized()); } var tests = await _context.Platforms.Where(x => x.PlatformName == testToCreate.PlatformName).Select(x => new { x.Tests, x.DbPlatformId }).FirstOrDefaultAsync(); if (tests == null) { return(BadRequest("Platform does not exist")); } if (tests.Tests.Select(x => x.TestName).Contains(testToCreate.TestName)) { return(Ok()); } var newTest = new DbTest { TestName = testToCreate.TestName, DbPlatformId = tests.DbPlatformId }; _context.Tests.Add(newTest); await _context.SaveChangesAsync(); return(Ok()); }
public int Create(TestCreate model) { return(testService.Create(model)); }