You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.2 KiB
45 lines
1.2 KiB
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Windows;
|
|
|
|
namespace eCompanies
|
|
{
|
|
/// <summary>
|
|
/// Логика взаимодействия для App.xaml
|
|
/// </summary>
|
|
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<Company> getCompanies()
|
|
{
|
|
using (var db = new CompaniesDBContext())
|
|
return new ObservableCollection<Company>(db.Company.AsEnumerable());
|
|
}
|
|
|
|
public static HashSet<Users> getUsers(int id)
|
|
{
|
|
using (var db = new CompaniesDBContext())
|
|
return new HashSet<Users>(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();
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|