コード例 #1
0
        public ActionResult<ToDoItem> CreateToDoItem(ToDoItem toDoItem)
        {
            if (toDoItem == null)
            {
                return BadRequest(new Dictionary<string, string>() { { "message", "To Do Item cannot be null" } });
            }
            if (toDoItem.Id == null)
            {
                return BadRequest(new Dictionary<string, string>() { { "message", "Id is required in the To Do Item" } });
            }
            if (toDoItem.Name == null)
            {
                return BadRequest(new Dictionary<string, string>() { { "message", "Name is required in the To Do Item" } });
            }
            if (toDoItem.IsComplete == null)
            {
                return BadRequest(new Dictionary<string, string>() { { "message", "IsComplete is required in the To Do Item" } });
            }

            return Ok(_service.UpsertToDoItem(toDoItem));
        }