Пример #1
0
 public static List <User> GetAllUsers(Guid walletGuid)
 {
     using (var context = new WalletDBContext())
     {
         return(context.Users.Where(u => u.Wallets.All(r => r.Guid != walletGuid)).ToList());
     }
 }
Пример #2
0
 public static User GetUserByGuid(Guid guid)
 {
     using (var context = new WalletDBContext())
     {
         return(context.Users.Include(u => u.Wallets).FirstOrDefault(u => u.Guid == guid));
     }
 }
Пример #3
0
 public static User GetUserByLogin(string login)
 {
     using (var context = new WalletDBContext())
     {
         return(context.Users.Include(u => u.Wallets).FirstOrDefault(u => u.Login == login));
     }
 }
Пример #4
0
 public static bool UserExists(string login)
 {
     using (var context = new WalletDBContext())
     {
         return(context.Users.Any(u => u.Login == login));
     }
 }
Пример #5
0
 public static void SaveWallet(Wallet wallet)
 {
     using (var context = new WalletDBContext())
     {
         context.Entry(wallet).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Пример #6
0
 public static void AddUser(User user)
 {
     using (var context = new WalletDBContext())
     {
         context.Users.Add(user);
         context.SaveChanges();
     }
 }
Пример #7
0
 public static void AddWallet(Wallet wallet)
 {
     using (var context = new WalletDBContext())
     {
         wallet.DeleteDatabaseValues();
         context.Wallets.Add(wallet);
         context.SaveChanges();
     }
 }
Пример #8
0
 public static void DeleteWallet(Wallet selectedWallet)
 {
     using (var context = new WalletDBContext())
     {
         selectedWallet.DeleteDatabaseValues();
         context.Wallets.Attach(selectedWallet);
         context.Wallets.Remove(selectedWallet);
         context.SaveChanges();
     }
 }