Esempio n. 1
0
        public async Task <JsonResult> CreateBug(BugViewModel bugToCreate)
        {
            var dbBug = BugViewModelHelpers.ConvertToDatabaseModel(bugToCreate);
            var newId = await _bugService.CreateBug(dbBug);

            return(MessageResult($"Create bug action completed, new Id: {newId}", newId > 0));
        }
Esempio n. 2
0
        public JsonResult Search(string searchString)
        {
            var bugs = _bugService.Search(searchString).ToList();

            if (!bugs.Any())
            {
                return(ErrorResponse());
            }

            return(Json(BugViewModelHelpers.ConvertToViewModels(bugs)));
        }
Esempio n. 3
0
        public JsonResult GetById(int id)
        {
            var bug = _bugService.FindById(id);

            if (bug == null)
            {
                return(ErrorResponse("Not found"));
            }

            return(Json(BugViewModelHelpers.ConvertToViewModel(bug)));
        }
Esempio n. 4
0
        public void BugService_GetBookById_ReturnsOneBook()
        {
            // What is this test even testing?

            // Arrange
            var idForTest     = 1;
            var dbBook        = GetTestBookById(idForTest);
            var testViewModel = GetBugViewModels()
                                .FirstOrDefault(b => b.Id == idForTest);
            // Act
            var viewModel = BugViewModelHelpers.ConvertToViewModel(dbBook);

            // Assert
            Assert.Equal(testViewModel.Title, viewModel.Title);
            Assert.Equal(testViewModel.Description, viewModel.Description);
        }