public void AddToDoItem_EmptyTitle_ThrowsException()
        {
            //Arrange
            var model = new ToDoModel()
            {
                Description = "Test",
                Title       = string.Empty,
                UserId      = 5
            };

            Action action = () => _toDoItemService.AddToDoItem(model);

            var exception = Assert.Throws <ToDoException>(action);

            Assert.Equal("Title is required field", exception.Message);
        }
Exemplo n.º 2
0
 public ActionResult <ToDoItemDTO> AddToDoItem(ToDoItemDTO ToDoItem)
 {
     _logger.Info(() => "Api AddProduct");
     ToDoItem.CreatedBy = (long)HttpContext.Request.HttpContext.Items["Userid"];
     ToDoItem.UpdatedBy = (long)HttpContext.Request.HttpContext.Items["Userid"];
     _toDoItemService.AddToDoItem(ToDoItem);
     return(StatusCode((int)HttpStatusCode.OK, ToDoItem));
 }
Exemplo n.º 3
0
        public async Task <IActionResult> CreateItem(ToDoItemToAdd itemToAdd)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            await _itemService.AddToDoItem(itemToAdd);

            return(StatusCode(201));
        }
        public void Post([FromBody] ToDoModel model)
        {
            model.UserId = GetAuthorizedUserId();

            _toDoItemService.AddToDoItem(model);
        }
 /// <summary>
 /// Adds to do item.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <returns></returns>
 public ToDoItemDTO AddToDoItem(ToDoItemDTO item)
 {
     return(_todoItemService.AddToDoItem(item));
 }