Exemple #1
0
 /// <summary>
 /// Добавляет задачу в БД
 /// </summary>
 /// <param name="task"></param>
 private void AddTaskDb(Task task)
 {
     using (var context = new PlannerContext())
     {
         context.Tasks.Add(task);
         context.SaveChanges();
     }
 }
Exemple #2
0
 /// <summary>
 /// Добавляет категорию в БД
 /// </summary>
 /// <param name="category"> Категория </param>
 private void AddCategoryDb(Category category)
 {
     using (var context = new PlannerContext())
     {
         context.Categories.Add(category);
         context.SaveChanges();
     }
 }
Exemple #3
0
        /// <summary>
        /// Удаляет задачу
        /// </summary>
        /// <param name="id">Id задачи</param>
        public void DeleteTask(int id)
        {
            using (var context = new PlannerContext())
            {
                var task = context.Tasks.FirstOrDefault(x => x.Id == id);
                context.Tasks.Remove(task);
                context.SaveChanges();
            }

            Tasks = GetTasks();
        }
Exemple #4
0
        /// <summary>
        /// Снимает пометку просроченности у задачи
        /// </summary>
        /// <param name="taskId">Id задачи</param>
        public void UnOverdueTask(int taskId)
        {
            using (var context = new PlannerContext())
            {
                var task = context.Tasks.FirstOrDefault(x => x.Id == taskId);
                task.IsOverdue = false;
                context.SaveChanges();
            }

            Tasks = GetTasks();
        }
Exemple #5
0
        /// <summary>
        /// Завершает задачу
        /// </summary>
        /// <param name="taskId">Id задачи</param>
        public void FinishTask(int taskId)
        {
            using (var context = new PlannerContext())
            {
                var task = context.Tasks.FirstOrDefault(x => x.Id == taskId);
                task.FinishDate = DateTime.Now;
                task.IsFinished = true;
                context.SaveChanges();
            }

            Tasks = GetTasks();
        }
Exemple #6
0
 /// <summary>
 /// Редактирует задачу
 /// </summary>
 /// <param name="editedTask">Задача</param>
 public void EditTask(Task editedTask)
 {
     using (var context = new PlannerContext())
     {
         var task = context.Tasks.FirstOrDefault(x => x.Id == editedTask.Id);
         task.Name         = editedTask.Name;
         task.CreationDate = editedTask.CreationDate;
         task.StartDate    = editedTask.StartDate;
         task.EndDate      = editedTask.EndDate;
         task.PriorityId   = editedTask.PriorityId;
         task.CategoryId   = editedTask.CategoryId;
         context.SaveChanges();
     }
 }