public static void AddUser(string name, string pw, int isadmin, string email, int isverified) { Users addThis = new Users(); using (var dbCtx = new GrafilogikaDBEntities()) { addThis.Name = name; addThis.Password = pw; addThis.Wins = 0; addThis.Mistakes = 0; addThis.Isadmin = isadmin; addThis.Email = email; addThis.Isverified = isverified; dbCtx.Users.Add(addThis); dbCtx.SaveChanges(); } }
public static void UpdateUserWins(Users usr) { using (var dbCtx = new GrafilogikaDBEntities()) { try { if (usr.Wins == null) { usr.Wins = 0; } usr.Wins++; dbCtx.Entry(usr).State = EntityState.Modified; dbCtx.SaveChanges(); } catch (Exception) { throw; } } }
public ActionResult ChangeAdmins(Users selectedUser) { DBManager.UpdateUserAdmin(selectedUser.Name); return RedirectToAction("AdminPage","Home"); }