コード例 #1
0
        public IActionResult CreateCategory()
        {
            var subjects = this.subjectService.GetSubjects().ToList();

            var model = new CategoryAdminCreateViewModel()
            {
                Subjects = this.mapper.Map <List <SubjectViewModel> >(subjects),
            };

            return(this.View(model));
        }
コード例 #2
0
        public async Task <IActionResult> CreateCategoryAsync(CategoryAdminCreateViewModel model)
        {
            if (this.ModelState.IsValid)
            {
                var category = new Category
                {
                    Id        = Guid.NewGuid().ToString(),
                    SubjectId = model.SubjectId,
                    Title     = model.Title,
                };
                await this.subjectService.CreateCategoryAsync(category);
            }
            else
            {
                this.ModelState.AddModelError(string.Empty, "Моля попълнете всички полета.");
                return(this.View(model));
            }

            return(this.Json("/Subject/AddLesson"));
        }