Exemplo n.º 1
0
 public static Exception IncrementCountOfWin(User currentUser)
 {
     using (TicTacToeDBEntities db = new TicTacToeDBEntities())
     {
         try
         {
             var user = db.Users.Where(u => u.Login == currentUser.Login).FirstOrDefault();
             user.CountOfWin++;
             db.SaveChanges();
             return(null);
         }
         catch (Exception ex)
         {
             return(ex);
         }
     }
 }
Exemplo n.º 2
0
 public static Exception AddUser(User user)
 {
     using (TicTacToeDBEntities db = new TicTacToeDBEntities())
     {
         try
         {
             var exist = db.Users.Where(u => u.Login == user.Login).FirstOrDefault();
             if (exist == null)
             {
                 db.Users.Add(user);
                 db.SaveChanges();
                 return(null);
             }
             else
             {
                 return(new Exception());
             }
         }
         catch (Exception ex)
         {
             return(ex);
         }
     }
 }