예제 #1
0
        public async Task InsertChangeLog()
        {
            var options = TestHelper.GetDbContext("InsertChangeLog");

            //Given
            var model = new ChangeLog()
            {
                VersionNumber = "1.0",
                ReleaseDate   = DateTime.Now.AddMonths(-2),
                Log           = "Log 1",
                Published     = true
            };

            using (var context = new DataContext(options))
            {
                var service = new ChangeLogService(context);

                //When
                var result = await service.InsertChangeLog(model);

                //Then
                Assert.True(result.Success);

                var actual = await context.ChangeLog.FindAsync(((ChangeLog)result.Tag).Id);

                Assert.Equal(model.VersionNumber, actual.VersionNumber);
                Assert.Equal(model.ReleaseDate, actual.ReleaseDate);
                Assert.Equal(model.Published, actual.Published);
                Assert.Equal(model.Log, actual.Log);
            }
        }
        public async Task <IActionResult> Insert([FromBody] ChangeLog changeLog)
        {
            var result = await ChangeLogService.InsertChangeLog(changeLog);

            if (!result.Success)
            {
                return(BadRequest(result.ValidationFailures));
            }

            return(Ok(result));
        }