Example #1
0
        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);
        }
Example #2
0
 private async Task <bool> DevelopersExists(int id)
 {
     return(await _developerRepostiory.Exist(id));
 }