Exemplo n.º 1
0
        internal static void EditSubject(ApplicationDbContext context, CollegeSubject collegeSubject)
        {
            var collegeSubjectToUpdate = context.CollegeSubjects.Where(c => c.Id == collegeSubject.Id).FirstOrDefault();

            collegeSubjectToUpdate.SubjectName  = collegeSubject.SubjectName;
            collegeSubjectToUpdate.SubjectAlias = collegeSubject.SubjectAlias;
            collegeSubjectToUpdate.CollegeId    = collegeSubject.CollegeId;
            context.SaveChanges();
        }
Exemplo n.º 2
0
 public CollegeSubjectDialog(CollegeSubject collegeSubject = null)
 {
     InitializeComponent();
     this.CollegeSubject = collegeSubject ?? new CollegeSubject();
     GridFormCollegeSubject.DataContext = CollegeSubject;
     collegesCombo.ItemsSource          = _db.Colleges.ToList();
     collegesCombo.DisplayMemberPath    = "CollegeName";
     collegesCombo.SelectedValuePath    = "Id";
     mayClose = false;
 }
Exemplo n.º 3
0
 public static CollegeSubject AddCollegeSubject(ApplicationDbContext context, CollegeSubject subject)
 {
     try {
         context.CollegeSubjects.Add(subject);
         context.SaveChanges();
     }
     catch (Exception ex) {
         MessageBox.Show("Curso não criado.", "Erro");
     }
     MessageBox.Show("Curso criado com sucesso.", "Sucesso");
     return(subject);
 }
Exemplo n.º 4
0
        private void ButtonEdit_Click(object sender, RoutedEventArgs e)
        {
            CollegeSubject employeeEdit = subjectGrd.SelectedItem as CollegeSubject;

            if (employeeEdit == null)
            {
                return;
            }
            CollegeSubjectDialog collegeSubjectDialog = new CollegeSubjectDialog(new CollegeSubject(employeeEdit))
            {
                Title = "Editar Curso"
            };

            if (collegeSubjectDialog.ShowDialog() == true)
            {
                DbContextHelper.EditSubject(_db, collegeSubjectDialog.CollegeSubject);
                subjectGrd.Items.Refresh();
            }
        }