protected virtual async Task <bool> ValidateModel(EditDeveloperViewModel model, Developer original = null) { if ((original == null || model.Nickname != original.Nickname) && await _developerRepo.Exist(model.Nickname)) { ModelState.AddModelError(nameof(model.Nickname), String.Format("Developer with nickname {0} already exists", model.Nickname)); } if (Regex.IsMatch(model.Nickname, "-")) { ModelState.AddModelError(nameof(model.Nickname), String.Format("Developer nickname should not contain \"-\" (dash) character")); } return(ModelState.IsValid); }
private async Task <bool> DevelopersExists(int id) { return(await _developerRepostiory.Exist(id)); }