private mainForm(user loggedUser, IUserContext userContext) { this.loggedUser = loggedUser; this.userContext = userContext; this.presenter= new mainFormPresenter(this, userContext); InitializeComponent(); prepare(); WireEvents(); }
public static mainForm getInstance(user loggedUser, IUserContext userContext) { if (instance == null || instance.IsDisposed) { instance = new mainForm(loggedUser, userContext); } return instance; }
public static user newUser(string username, string hashedPassword, string accountType) { user newUser = new user() { username = username, password = hashedPassword, accountType = accountType }; return newUser; }
public editUser(user user, IUserContext db) { this.user = user; this.userContext = db; this.presenter = new editUserPresenter(this, userContext); InitializeComponent(); loadComboBoxAccountType(); loadValues(user); wireEvents(); }
public void addUser(user user) { query("INSERT INTO ser(`username`, `password`, `accounttype`) VALUES (?,?,?)", new Dictionary<string, string>() { {"@username", user.username}, {"@password", user.password}, {"@accounttype", user.accountType} } ); }
public void addUser(user user) { Entry(user).State = EntityState.Added; SaveChanges(); }
public bool usernameAlreadyUsed(string username, user owner) { user output = user.FirstOrDefault(u => u.username == username && u.id != owner.id); if (output == null) { return false; } else { return true; } }
public void updateUserById(int id, user UpdatedUser) { user user = getUserById(id); user.username = UpdatedUser.username; user.accountType = UpdatedUser.accountType; Entry(user).State = EntityState.Modified; SaveChanges(); }
public void deleteUserById(user user) { throw new NotImplementedException(); }
public void editUser(user user) { db.updateUserById(user.id, user); }
public void addUser(user user) { db.addUser(user); }
public bool usernameAlreadyUsed(string username, user owner) { query("SELECT COUNT(`id`) FROM user WHERE username = ? AND id != ?", new Dictionary<string, string>() { {"@username", username}, {"@id", owner.id.ToString()} } ); if (int.Parse(result.Rows[0][0].ToString()) > 0) { return true; } else { return false; } }