コード例 #1
0
ファイル: Admin.cs プロジェクト: darkpchela/CourseProject
        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");
            }
        }