示例#1
0
        public bool Delete(int id)
        {
            var dbEntity = _toDoListRepository.Delete(id);

            _unitOfWork.Commit();
            return(dbEntity);
        }
示例#2
0
        public async Task <IActionResult> DeleteToDoListItem(int userId, int id)
        {
            if (userId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }

            var itemToDelete = await _repo.GetItem(id);

            if (itemToDelete == null)
            {
                return(NotFound());
            }

            if (userId != itemToDelete.UserId)
            {
                return(Unauthorized());
            }

            _repo.Delete(itemToDelete);

            if (await _repo.SaveAll())
            {
                return(Ok());
            }

            return(BadRequest("Failed to delete the list item"));
        }
示例#3
0
        public ActionResult DeleteConfirmed(int id)
        {
            todolistRepository.Delete(id);
            todolistRepository.Save();

            return(RedirectToAction("Index"));
        }
 public int Delete(int Id)
 {
     if (string.IsNullOrWhiteSpace(Id.ToString()))
     {
         return(result);
     }
     else
     {
         return(_toDoListRepository.Delete(Id));
     }
 }
        public IActionResult DeleteToDoList(int toDoListID)
        {
            try
            {
                _toDoListRepository.Delete(toDoListID);

                return(Ok());
            } catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
示例#6
0
 public IActionResult Deletar([FromBody] ToDoList todolist)
 {
     try
     {
         /// produto da requisicao deve tar a propriedade do Id > 0 para conseguir remover.
         _todolistRepository.Delete(todolist);
         return(Json(_todolistRepository.GetAll()));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.ToString()));
     }
 }
示例#7
0
        public async Task <IActionResult> DeleteToDoList(string id, string sfObject)
        {
            var response = await _toDoListRepo.Delete(id, sfObject);

            if (response)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                return(View());
            }
        }
示例#8
0
 public ActionResult Delete(ToDoList model)
 {
     try
     {
         ToDoList _newTask = new ToDoList();
         _newTask = toDoListRepository.Details(model.ToDoListID);
         toDoListRepository.Delete(_newTask);
         return(RedirectToAction("index"));
     }
     catch
     {
         return(View());
     }
 }
示例#9
0
        public ActionResult Delete(int id, todolist items)
        {
            try
            {
                // TODO: Add delete logic here
                toDoListRepository.Delete(id);

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
示例#10
0
        public void DeleteTest()
        {
            ToDoLists.Lists.Add(1, new List <ToDoList>());
            ToDoList list = new ToDoList
            {
                UserID = 1,
                Title  = "Test List"
            };

            var insert = _toDoListRepository.Create(list);

            _toDoListRepository.Delete(insert.ID);

            Assert.AreEqual(0, ToDoLists.Lists[1].Count);
        }
示例#11
0
        public async Task DeleteTask(DeleteToDoTask command)
        {
            var existingTask = await _toDoRepository.GetById(command.TaskId);

            if (existingTask == null)
            {
                throw new Exception("can't update task - id not found");
            }

            if (existingTask.UserId != command.UserId)
            {
                throw new Exception("can't update task - wrong user");
            }

            await _toDoRepository.Delete(command.TaskId);
        }
 public int Delete(int Id)
 {
     return(_todolistRepository.Delete(Id));
     //throw new NotImplementedException();
 }
示例#13
0
 public int Delete(int id)
 {
     return(_toDoListRepository.Delete(id));
 }
示例#14
0
 public void Delete(ToDoList task)
 {
     _ToDoListRepository.Delete(task);
     Save();
 }