Beispiel #1
0
        private static void InsertTaskTest()
        {
            var taskRepository = new DapperTaskRepository();
            var task           = new DataLayer.Entities.Task();

            Console.WriteLine("Enter task title");
            task.Title = Console.ReadLine();

            Console.WriteLine("Enter task description");
            task.Description = Console.ReadLine();

            Console.WriteLine("Enter task status");
            task.Status = (DataLayer.Enums.Status) int.Parse(Console.ReadLine());

            Console.WriteLine("Enter task type");
            task.Type = (DataLayer.Enums.TaskType) int.Parse(Console.ReadLine());

            Console.WriteLine("Enter task priority");
            task.Priority = (DataLayer.Enums.Priority) int.Parse(Console.ReadLine());

            taskRepository.AddAsync(task).GetAwaiter().GetResult();
            Console.WriteLine($"Id of the new inserted task: {task.Id}");

            Console.ReadLine();
        }
Beispiel #2
0
        private static void GetAllTasksTest()
        {
            var taskRepository = new DapperTaskRepository();
            IEnumerable <DataLayer.Entities.Task> tasks = taskRepository.GetAllAsync()
                                                          .GetAwaiter()
                                                          .GetResult();

            foreach (var task in tasks)
            {
                PrintTask(task);
            }
            Console.WriteLine("Finished with tasks printing");
        }
Beispiel #3
0
        private static void DeleteTaskTest()
        {
            var taskRepository = new DapperTaskRepository();

            Console.WriteLine("Enter existing task id");
            var id = int.Parse(Console.ReadLine());

            var task = taskRepository.GetByIdAsync(id).GetAwaiter().GetResult();

            if (task == null)
            {
                Console.WriteLine($"Task with id: {id} does not exist");
                return;
            }


            taskRepository.RemoveAsync(task).GetAwaiter().GetResult();
            Console.WriteLine("Successful delete");

            Console.ReadLine();
        }
        static void Main(string[] args)
        {
            //InsertTaskTest();

            //UpdateTaskTest();
            //DeleteTaskTest();
            //GetCountTest();
            //Console.ReadLine();

            var taskRepository = new DapperTaskRepository();
            IEnumerable <DataLayer.Entities.Task> tasks = taskRepository.GetAllAsync()
                                                          .GetAwaiter()
                                                          .GetResult();

            foreach (var task in tasks)
            {
                Console.WriteLine("---------------------------------------------------");
                Console.WriteLine($"Task Id:{task.Id} Title:{task.Title} Description:{task.Description} Priority:{task.Priority} Status:{task.Status} Type:{task.Type}");
                foreach (var subtask in task.SubTasks)
                {
                    Console.WriteLine($"Subtask Id: {subtask.Id}, Title: {subtask.Title}, Description: {subtask.Description}, Status: {subtask.Status},  ");
                }
                Console.WriteLine("---------------------------------------------------");
            }
            Console.WriteLine("Finished with tasks printing");
            //Console.WriteLine("Enter task id:");
            //int taskId = int.Parse(Console.ReadLine());
            //var task = taskRepository.GetByIdAsync(taskId).GetAwaiter().GetResult();
            //string taskId = Console.ReadLine();
            //var task = taskRepository.GetById(taskId);

            //Console.WriteLine("Enter task title:");
            //string taskTitle = Console.ReadLine();
            //var task = taskRepository.GetByTitle(taskTitle);

            //Console.WriteLine($"Task Id:{task.Id} Title:{task.Title} Description:{task.Description} Priority:{task.Priority} Status:{task.Status} Type:{task.Type}");
            Console.ReadLine();
        }