예제 #1
0
        private void DeleteOneLearning(object sender, MouseButtonEventArgs e)
        {
            var id = int.Parse(((Image)sender).Tag.ToString());
            var l  = context.Learnings.Include(g => g.Achivments).FirstOrDefault(g => g.LearningId == id);
            var l1 = context.Learnings.Include(g => g.Achivments).FirstOrDefault(g => g.LearningId == id).Achivments;

            context.Learnings.Remove(l);
            context.SaveChanges();
            LearningsList.ItemsSource = query.AjaxLearning(CurrentIdSection);
            context.Achivments.RemoveRange(l1);
            context.SaveChanges();
        }
예제 #2
0
        private void EditAchivment(object sender, RoutedEventArgs e)
        {
            var hack = context.Learnings.Include(g => g.Section);
            var y    = hack.AsEnumerable().FirstOrDefault(g => g.Achivments.Contains(l)).Section.SectionId;

            //var id = y.Section.SectionId;
            // MessageBox.Show(y.ToString());
            ///UPDATE
            if (NewName.Text.Length == 0 || Result.Text.Length == 0 || Desc.Text.Length == 0)
            {
                return;
            }
            l.Name        = NewName.Text;
            l.Result      = Result.Text;
            l.Description = Desc.Text;
            var task = Task <int> .Factory.StartNew(() =>
            {
                return(context.SaveChanges());
            });

            task.Wait();
            // MessageBox.Show(task.IsCompleted == true ? "Выполнено" : "Ошибка");
            var w = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault();

            w.Body.Content = new Learnings(y);
            Close();
        }
예제 #3
0
        private void Editing(object sender, RoutedEventArgs e)
        {
            if (s == null)
            {
                MessageBox.Show("Данные не загружены!!");
            }
            if (NewName.Text.Length == 0)
            {
                return;
            }
            if (s != null)
            {
                s.Name = NewName.Text;
                var task = Task <int> .Factory.StartNew(() =>
                {
                    return(context.SaveChanges());
                });

                task.Wait();
                // MessageBox.Show(task.IsCompleted == true ? "Выполнено" : "Ошибка сохранения");
                var w = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault();
                w.Sections.ItemsSource = context.Sections.ToList();
                Close();
            }
        }
예제 #4
0
        private void AddLearning(object sender, RoutedEventArgs e)
        {
            if (s == null)
            {
                MessageBox.Show("Данные не загружены!!");
            }
            if (NewName.Text.Length == 0 || NewFamily.Text.Length == 0)
            {
                return;
            }
            if (s != null)
            {
                var l = new Learning();
                l.Name    = NewFamily.Text;
                l.Family  = NewName.Text;
                l.Section = s;
                s.Learnings.Add(l);
                var task = Task <int> .Factory.StartNew(() =>
                {
                    return(context.SaveChanges());
                });

                task.Wait();
                // MessageBox.Show(task.IsCompleted == true ? "Выполнено" : "Ошибка сохранения");
                var w = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault();
                w.Body.Content = new Learnings(CurrentId);
                Close();
            }
        }
예제 #5
0
        private void DeleteSection(object sender, MouseButtonEventArgs e)
        {
            int id = Convert.ToInt32(((Image)sender).Tag);

            using (BasicLadaContext c = new BasicLadaContext())
            {
                var t = c.Sections.Include(b => b.Learnings).FirstOrDefault(g => g.SectionId == id);
                c.Sections.Remove(t);
                c.SaveChanges();
                Sections.ItemsSource = c.Sections.ToList();
            }
            if (context.Sections.FirstOrDefault() != null)
            {
                Body.Content = new Learnings(context.Sections.FirstOrDefault().SectionId);
            }
            else
            {
                Body.Content = new Startup();
            }
        }
예제 #6
0
        private void AddAchivment(object sender, RoutedEventArgs e)
        {
            var learning = context.Learnings.Include(g => g.Section).FirstOrDefault(g => g.LearningId == CurrentLearningId);
            var id       = learning.Section.SectionId;
            var section  = context.Sections.FirstOrDefault(s => s.SectionId == id);

            if (NewName.Text.Length == 0 ||
                Result.Text.Length == 0 ||
                Desc.Text.Length == 0 ||
                Level.Text == null ||
                Type.Text == null ||
                dialog.FileName.Length == 0)
            {
                MessageBox.Show("Empty");
                return;
            }
            var achiv = new Achivment()
            {
                Name        = NewName.Text,
                Result      = Result.Text,
                Description = Desc.Text,
                Level       = Level.SelectedItem as string,
                Type        = Type.SelectedItem as string,
                Image       = ImageName.Text
            };

            learning.Achivments.Add(achiv);
            section.Achivments.Add(achiv);
            var task = Task <int> .Factory.StartNew(() =>
            {
                return(context.SaveChanges());
            });

            task.Wait();
            // MessageBox.Show(task.IsCompleted ? "Выполнено" : "Ошибка создания");
            var w = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault();

            w.Body.Content = new Learnings(id);
            Close();
        }
예제 #7
0
        private void EditLearning(object sender, RoutedEventArgs e)
        {
            var id = l.Section.SectionId;

            if (NewName.Text.Length == 0 || NewFamily.Text.Length == 0)
            {
                return;
            }
            l.Name   = NewName.Text;
            l.Family = NewFamily.Text;
            var task = Task <int> .Factory.StartNew(() =>
            {
                return(context.SaveChanges());
            });

            task.Wait();
            // MessageBox.Show(task.IsCompleted == true ? "Выполнено" : "Ошибка");
            var w = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault();

            w.Body.Content = new Learnings(id);
            Close();
        }
예제 #8
0
        private void AddSection(object sender, RoutedEventArgs e)
        {
            BasicLadaContext c = new BasicLadaContext();

            s.Name = NewName.Text;
            if (NewName.Text.Length == 0)
            {
                return;
            }
            var task = Task <int> .Factory.StartNew(() =>
            {
                c.Sections.Add(s);
                return(c.SaveChanges());
            });

            task.Wait();
            // MessageBox.Show(task.IsCompleted == true ? "Выполнено" : "Ошибка создания");
            var w = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault();

            w.Sections.ItemsSource = c.Sections.ToList();
            Close();
        }