コード例 #1
0
        CreateList([FromBody] Models.Public.Request.List list)
        {
            var listObj = await _service.CreateList(list, getID());

            if (listObj != null)
            {
                return(Ok(listObj));
            }
            return(BadRequest());
        }
コード例 #2
0
        public ActionResult Create(CreateListViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("MyLists"));
            }

            try
            {
                ListService.CreateList(viewModel);
            }
            catch
            {
                throw;
            }

            return(RedirectToAction("MyLists"));
        }
コード例 #3
0
        public IActionResult PostList([FromBody] ListBLL list, [FromRoute] int userId)
        {
            try
            {
                if (list.Title == null)
                {
                    return(BadRequest());
                }
                list.User = userId;
                list.Id   = listService.CreateList(list);

                return(Ok(list));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
コード例 #4
0
        public async Task CreateList_ShouldCallListRepositoryAdd()
        {
            // Data
            var listModel = new ListModel {
                Name = "todo list", Id = Guid.NewGuid()
            };

            // Setup
            _mockListRepository.Setup(x => x.Add(It.Is <Data.Entities.List>(y => y.Name == listModel.Name)))
            .Returns(Task.CompletedTask).Verifiable();

            // Test
            var listService = new ListService(_mockListRepository.Object);
            await listService.CreateList(listModel);

            // Analysis
            _mockListRepository.Verify();
        }