示例#1
0
        public async Task <IActionResult> Themes()
        {
            var themes = await themesCrudService.GetAllAsync();

            var vms = mapper.Map <IEnumerable <ThemeVM> >(themes);

            return(View(vms));
        }
示例#2
0
        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");
            }
        }
示例#3
0
        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");
            }
        }