Exemplo n.º 1
0
 public void UpdateCurrentCompany(Company company)
 {
     var entity = _context.Companies.Find(company.Id);
     if (entity == null)
     {
         MessageBox.Show("Данная сущность не найдена.", "Ошибка!", MessageBoxButton.OK);
         return;
     }
     _context.Entry(company).CurrentValues.SetValues(company);
     _context.SaveChanges();
 }
Exemplo n.º 2
0
 public void DeleteCurrentCompany(Company company)
 {
     var companyToUpdate = _context.Companies.SingleOrDefault(e => e.Id == company.Id);
     if (companyToUpdate == null)
     {
         MessageBox.Show("Данная сущность не найдена.", "Ошибка!", MessageBoxButton.OK);
         return;
     }
     _context.Companies.Remove(companyToUpdate);
     _context.SaveChanges();
 }
Exemplo n.º 3
0
 public void CancelUpdateCurrentCompany(Company company)
 {
     var entity = _context.Companies.Find(company.Id);
     if (entity == null)
     {
         MessageBox.Show("Данная сущность не найдена.", "Ошибка!", MessageBoxButton.OK);
         return;
     }
     _context.Entry(company).Reload();
 }
Exemplo n.º 4
0
 public void AddNewCompany(Company company)
 {
     _context.Companies.Add(company);
     _context.SaveChanges();
 }