示例#1
0
        public void AddListTest()
        {
            ToDoLists.Lists.Add(1, new List <ToDoList>());
            ToDoList toDoList = new ToDoList
            {
                UserID = 1,
                Title  = "Test List"
            };

            var insertedToDo = _toDoListRepository.Create(toDoList);

            Assert.AreEqual(1, insertedToDo.ID);
        }
 public int Create(ToDoListVM toDoListVM)
 {
     if (string.IsNullOrWhiteSpace(toDoListVM.Name))
     {
         return(result);
     }
     else
     {
         return(_toDoListRepository.Create(toDoListVM));
     }
 }
        public IActionResult AddToDoList([FromBody] ToDoList toDoList)
        {
            try
            {
                var insertedToDoList = _toDoListRepository.Create(toDoList);

                return(Json(insertedToDoList));
            } catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
        public void AddListItem()
        {
            ToDoLists.Lists.Add(1, new List <ToDoList>());
            ToDoList toDoList = new ToDoList
            {
                UserID = 1,
                Title  = "Test List"
            };

            var insertedToDoList = _toDoListRepository.Create(toDoList);

            var toDoListItem = new ToDoListItem
            {
                UserID     = 1,
                Title      = "Test Item 1",
                ToDoListID = insertedToDoList.ID,
                Content    = "Lorem ipsum dolor sit amet, consectetur adipiscing elit"
            };

            var insertedItem = _toDoListItemRepository.Create(toDoListItem);

            Assert.AreEqual(1, insertedItem.ID);
        }
示例#5
0
        public async Task CreateTask(CreateNewToDoTask command)
        {
            var existingTask = await _toDoRepository.GetById(command.TaskId);

            if (existingTask != null)
            {
                throw new Exception("can't create task - id already present");
            }

            await _toDoRepository.Create(
                new ToDoTask()
            {
                CreationDateTimeOffset = DateTimeOffset.Now,
                Description            = command.Description,
                Id        = command.TaskId,
                IsChecked = false,
                ModificationDateTimeOffset = DateTimeOffset.Now,
                UserId = command.UserId
            });
        }
 public int Create(ToDoListVM toDoListVM)
 {
     return(_todolistRepository.Create(toDoListVM));
     //throw new NotImplementedException();
 }
示例#7
0
 public int Create(ToDoListVM toDoListVM)
 {
     return(_toDoListRepository.Create(toDoListVM));
 }
示例#8
0
 public Task Create(ToDoList toDoList) => _toDoListRepository.Create(toDoList);