示例#1
0
        public void create_new_todo_list()
        {
            service.CreateList(new TodoList {
                Id = 1, Name = "1st List"
            });
            service.CreateList(new TodoList {
                Id = 1, Name = "2nd List"
            });
            var lists = service.GetTodoLists();

            Assert.IsTrue(lists.Result.Count > 1);
        }
示例#2
0
 public void AddTodoList([FromBody] ModifyTodoListDTO dto)
 {
     if (String.IsNullOrEmpty(dto.Title))
     {
         throw new SX.Common.Shared.Exceptions.CustomInputException("Empty Todo-List Title!");
     }
     _todoService.CreateList(dto.Title);
 }
        public IActionResult PostTodoList([FromBody]TodoList list)
        {
            if (!ModelState.IsValid)
                return BadRequest(ModelState);

            int createdId;
            try
            {
                createdId = _service.CreateList(list);
            }
            catch (Exception ex)
            {
                return BadRequest(ex.Message);
            }

            return CreatedAtAction("PostTodoList", new { id = createdId }, list);
        }
        public IActionResult PostTodoList([FromBody] TodoList list)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            int createdId;

            try
            {
                createdId = _service.CreateList(list);
            }
            catch
            {
                return(BadRequest());
            }

            return(CreatedAtAction("PostTodoList", new { id = createdId }, list));
        }