示例#1
0
 public string AddUser(Registration registration)
 {
     try
     {
         string status = "";
         if (registration != null)
         {
             if (!CheckingData(registration, ref status))
             {
                 return(status);
             }
             else
             {
                 if (GetUser(registration))
                 {
                     db.Users.Add(new User()
                     {
                         UserName        = registration.UserName,
                         SubUserName     = registration.SubUserName,
                         SubUserPassword = registration.SubUserPassword,
                         UserPassword    = registration.UserPassword
                     });
                     db.SaveChanges();
                     db.Wallets.Add(new Wallet()
                     {
                         CardNumber  = registration.CardNumber,
                         YearExpire  = registration.YearExpire,
                         MonthExpire = registration.MonthExpire,
                         CW2         = registration.CW2
                     });
                     db.SaveChanges();
                     db.Accounts.Add(new Account()
                     {
                         User   = db.Users.FirstOrDefault(u => u.UserName == registration.UserName),
                         Wallet = db.Wallets.Where(cn => cn.CardNumber == registration.CardNumber).
                                  FirstOrDefault(cw => cw.CW2 == registration.CW2),
                         Balance = 0
                     });
                     db.SaveChanges();
                     return(registration.UserName);
                 }
                 return("UserName bisy");
             }
         }
         else
         {
             return("Empty entity");
         }
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }
示例#2
0
 public void Add(Game game)
 {
     db.Games.Add(game);
     db.SaveChanges();
 }