Ejemplo n.º 1
0
 public static bool UserExists(string login)
 {
     try
     {
         using (var context = new DirFileCounterContext())
         {
             return(context.Users.Any(u => u.Login == login));
         }
     }
     catch (Exception ex)
     {
         throw new CounterDbException("User exists exception", ex.InnerException);
     }
 }
Ejemplo n.º 2
0
 public static User GetUserByGuid(Guid guid)
 {
     try
     {
         using (var context = new DirFileCounterContext())
         {
             return(context.Users.Include(u => u.Requests).FirstOrDefault(u => u.Guid == guid));
         }
     }
     catch (Exception ex)
     {
         throw new CounterDbException("Get user by guid exception", ex.InnerException);
     }
 }
Ejemplo n.º 3
0
 public static User GetUserByLogin(string login)
 {
     try
     {
         using (var context = new DirFileCounterContext())
         {
             return(context.Users.Include(u => u.Requests).FirstOrDefault(u => u.Login == login));
         }
     }
     catch (Exception ex)
     {
         throw new CounterDbException("Get user by login exception", ex.InnerException);
     }
 }
Ejemplo n.º 4
0
 public static void AddUser(User user)
 {
     try
     {
         using (var context = new DirFileCounterContext())
         {
             context.Users.Add(user);
             context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw new CounterDbException("Add user exception", ex.InnerException);
     }
 }
Ejemplo n.º 5
0
 public static void AddRequest(Request request)
 {
     try
     {
         using (var context = new DirFileCounterContext())
         {
             request.DeleteDatabaseValues();
             context.Requests.Add(request);
             context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw new CounterDbException("Add request exception", ex.InnerException);
     }
 }