public void RegisterAccount(string username, string password) { //get the account first Name name = _context.Name.FirstOrDefault(n => !n.HasRegistered && string.Equals(n.RegisteredName, username, StringComparison.InvariantCultureIgnoreCase)); if (name != null) { //SHA256 hash the password string hashed = hashPassword(password); name.Password = hashed; name.HasRegistered = true; _context.SaveChanges(); } else { //TODO: New Exception throw new Exception("This user is already registered."); } }
public void RemoveMatch(string requestor, string matchedName) { var matchToRemove = _context.Matches.First(m => string.Equals(m.RequestorName, requestor, StringComparison.InvariantCultureIgnoreCase) && string.Equals(m.MatchedName, matchedName, StringComparison.InvariantCultureIgnoreCase)); if (matchToRemove != null) { _context.Matches.Remove(matchToRemove); _context.SaveChanges(); } }