예제 #1
0
        public async Task <IActionResult> Create(CreateCategoryInputViewModel model)
        {
            var userId     = this.userManager.GetUserId(this.User);
            var categoryId = await this.categoriesService.CreateCategoryAsync(model.Name, userId);

            return(this.RedirectToAction("AssignQuizzesToCategory", new { id = categoryId }));
        }
예제 #2
0
        public async Task <bool> Create(CreateCategoryInputViewModel model, string imageUploadResult)
        {
            if (model.Name == null ||
                model.Description == null)
            {
                return(false);
            }

            var category = new Category
            {
                Name                   = model.Name,
                Description            = model.Description,
                CategoryVersionPicture = imageUploadResult
            };

            this._dbContext.Categories.Add(category);
            await this._dbContext.SaveChangesAsync();

            return(true);
        }