public void DeleteTask(Task task)
        {
            Task deletetask = (Task)taskList.SelectedItem;

            Services.DeleteTask(deletetask);
            MessageBox.Show("Записът е изтрит");
            BindTasks();
        }
 public void DeleteTask(Task record)
 {
     using (BM_DatabaseEntities db = new BM_DatabaseEntities())
     {
         var task = db.Tasks.FirstOrDefault(t => t.Id == record.Id);
         db.Tasks.Attach(task);
         db.Tasks.Remove(task);
         db.SaveChanges();
     }
 }
        public void SaveSchedule(Task task)
        {
            Task tasks = new Task();

            tasks.TaskName  = Box_TaskName.Text;
            tasks.DateStart = Date1.SelectedDate.Value;
            tasks.DateEnd   = Date2.SelectedDate.Value;
            Services.SaveTask(tasks);
            MessageBox.Show("Успешно добавен запис!");
            BindTasks();
        }
        public Task SaveTask(Task record)
        {
            using (BM_DatabaseEntities db = new BM_DatabaseEntities())
            {
                try
                {
                    db.Tasks.Add(record);
                    db.SaveChanges();
                }

                catch (DbEntityValidationException ee)
                {
                    foreach (var error in ee.EntityValidationErrors)
                    {
                        foreach (var thisError in error.ValidationErrors)
                        {
                            var errorMessage = thisError.ErrorMessage;
                        }
                    }
                }
                return(record);
            }
        }
Exemple #5
0
 public static void DeleteTask(Task obj)
 {
     _repository.DeleteTask(obj);
 }
Exemple #6
0
 public static void SaveTask(Task obj)
 {
     _repository.SaveTask(obj);
 }