示例#1
0
 public static List <User> GetAllUsers(Guid conversionGuid)
 {
     using (var context = new ConversionDBContext())
     {
         return(context.Users.Where(u => u.Conversions.All(r => r.Guid != conversionGuid)).ToList());
     }
 }
示例#2
0
 public static User GetUserByGuid(Guid guid)
 {
     using (var context = new ConversionDBContext())
     {
         return(context.Users.Include(u => u.Conversions).FirstOrDefault(u => u.Guid == guid));
     }
 }
示例#3
0
 public static User GetUserByLogin(string login)
 {
     using (var context = new ConversionDBContext())
     {
         return(context.Users.Include(u => u.Conversions).FirstOrDefault(u => u.Login == login));
     }
 }
示例#4
0
 public static bool UserExists(string login)
 {
     using (var context = new ConversionDBContext())
     {
         return(context.Users.Any(u => u.Login == login));
     }
 }
示例#5
0
 public static void SaveConversion(Conversion conversion)
 {
     using (var context = new ConversionDBContext())
     {
         context.Entry(conversion).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
示例#6
0
 public static void AddUser(User user)
 {
     using (var context = new ConversionDBContext())
     {
         context.Users.Add(user);
         context.SaveChanges();
     }
 }
示例#7
0
 public static void AddConversion(Conversion conversion)
 {
     using (var context = new ConversionDBContext())
     {
         conversion.DeleteDatabaseValues();
         context.Conversions.Add(conversion);
         context.SaveChanges();
     }
 }
示例#8
0
 public static void DeleteConversion(Conversion selectedConversion)
 {
     using (var context = new ConversionDBContext())
     {
         selectedConversion.DeleteDatabaseValues();
         context.Conversions.Attach(selectedConversion);
         context.Conversions.Remove(selectedConversion);
         context.SaveChanges();
     }
 }