public async Task <IActionResult> Themes() { var themes = await themesCrudService.GetAllAsync(); var vms = mapper.Map <IEnumerable <ThemeVM> >(themes); return(View(vms)); }
protected async override Task BaseValidation(CreateThemeModel model) { var theme = (await themesCrudService.GetAllAsync()).FirstOrDefault(t => t.Name == model.Name); if (theme != null) { ValidationResult.AddError("Theme with such name already exists"); } }
protected async override Task BaseValidation(UpdateThemeModel model) { var allThemes = await themesCrudService.GetAllAsync(); if (!allThemes.Any(t => t.Id == model.ThemeId)) { ValidationResult.AddError("Theme not found"); } if (allThemes.Any(t => t.Name == model.Name)) { ValidationResult.AddError("Theme with such name already exists"); } }