예제 #1
0
 public TestMinimal MapToBLL(TestCreate apiTest)
 {
     return(new TestMinimal
     {
         Id = 0,
         TestTypeId = apiTest.TestTypeId,
         TestName = apiTest.TestName
     });
 }
예제 #2
0
        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));
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
            }
        }
예제 #5
0
        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());
        }
예제 #6
0
 public int Create(TestCreate model)
 {
     return(testService.Create(model));
 }