Example #1
0
 private void ClearDb()
 {
     foreach (var item in _repo.GetAll())
     {
         _repo.Delete(item.Id);
     }
 }
Example #2
0
        //DELETE***********************************
        internal Todo Delete(string id)
        {
            Todo original = GetById(id);

            _repo.Delete(id);
            return(original);;
        }
        internal String Delete(int id)
        {
            // NOTE: Why do we declare data? We don't use it...
            Todo data = GetById(id);

            _repo.Delete(id);
            return("delorted");
        }
        internal void Delete(int id, string userId)
        {
            Todo original = Get(id);

            if (original.CreatorId != userId)
            {
                throw new Exception("You can't delete this.");
            }
            _todoRepo.Delete(id);
        }
Example #5
0
        private static void DeleteItem()
        {
            var todos = Repo.GetAll().ToList();

            TodoHelper.PrintTodoTable(todos);
            Console.Write("Enter the Todo item number to delete: ");
            var response = Console.ReadLine();

            if (int.TryParse(response, out var choice))
            {
                if (choice > 0 && choice <= todos.Count())
                {
                    Repo.Delete(todos.ElementAt(choice - 1).Id);
                }
                else
                {
                    Console.WriteLine("Invalid Choice! Try Again!!!\n\n");
                }
            }
        }