public OperationResult Register(User user) { CheckNullValues(user); Guard.ThrowIfLessThan(user.Name.Length, 3); Guard.ThrowIfLonger(user.Name, 50); if (provider.GetByMail(user.Mail) != null) return OperationResult.AlreadyRegistered; this.Create(user); return OperationResult.Success; }
public void Create(User user) { provider.Create(user); }
public OperationResult Update(User user) { provider.Update(user); return OperationResult.Success; }
void CheckNullValues(User user) { Guard.ThrowIfEmptyString(user.Mail); Guard.ThrowIfEmptyString(user.Name); Guard.ThrowIfEmptyGuid(user.Id); Guard.ThrowIfEmptyString(user.PasswordCrypted); }
public string GenerateToken(User user) { return MD5Hash(user.Name + user.Id + salt); }