CreateList([FromBody] Models.Public.Request.List list) { var listObj = await _service.CreateList(list, getID()); if (listObj != null) { return(Ok(listObj)); } return(BadRequest()); }
public ActionResult Create(CreateListViewModel viewModel) { if (!ModelState.IsValid) { return(RedirectToAction("MyLists")); } try { ListService.CreateList(viewModel); } catch { throw; } return(RedirectToAction("MyLists")); }
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)); } }
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(); }