private Boolean IsUniqueUsername(Int32 accountId, String username)
{
Boolean isUnique = !UnitOfWork
.Select<Account>()
.Any(account =>
account.Id != accountId &&
account.Username.ToLower() == username.ToLower());
if (!isUnique)
ModelState.AddModelError<AccountView>(model => model.Username, Validations.UniqueUsername);
return isUnique;
}
private Boolean IsUniqueEmail(Int32 accountId, String email)