using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data;
using System.Linq;
using System.Windows;
namespace eCompanies
{
///
/// Логика взаимодействия для App.xaml
///
public partial class App : Application
{
private void addCompany(Company c)
{
using (var db = new CompaniesDBContext())
{
db.Company.Add(c);
var count = db.SaveChanges();
}
}
public static ObservableCollection getCompanies()
{
using (var db = new CompaniesDBContext())
return new ObservableCollection(db.Company.AsEnumerable());
}
public static HashSet getUsers(int id)
{
using (var db = new CompaniesDBContext())
return new HashSet(db.Users.Where(b => b.CompanyId.Equals(id)));
}
public static void updateCompany(Company c)
{
using (var db = new CompaniesDBContext())
{
db.Company.Update(c);
db.SaveChanges();
}
}
}
}