Example #1
0
 public static User GetUser(int id)
 {
     try
     {
         var db   = new HostMakerEntities();
         var user = db.Users.FirstOrDefault(x => x.Id == id);
         return(user);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Example #2
0
 public static bool Authenticate(Credentials credentials)
 {
     try
     {
         var db   = new HostMakerEntities();
         var user = db.Users.FirstOrDefault(x => x.Login == credentials.Login && x.Password == credentials.Password);
         if (user is null)
         {
             return(false);
         }
         else
         {
             CookieManager.CreateCookieAuth <User, int>(user.Id);
             return(true);
         }
     }
     catch (Exception e)
     {
         Debug.WriteLine(e.Message);
         return(false);
     }
 }