public async Task Delete(string id)
        {
            CategoryViewModel categoryModel = this.Get(id);

            ShopApp.Models.Category categoryEntity = this.dbContext.Categories.FirstOrDefault(c => c.Id == categoryModel.Id);

            this.dbContext.Categories.Remove(categoryEntity);
            await this.dbContext.SaveChangesAsync();
        }
        public string GetDefaultCategory()
        {
            ShopApp.Models.Category defaultCategory = this._dbContext.Categories.FirstOrDefault();

            if (defaultCategory == null)
            {
                return(string.Empty);
            }

            return(defaultCategory.Name);
        }
        public async Task Edit(CategoryInputModel model)
        {
            ShopApp.Models.Category categoryEntity = this.dbContext.Categories.FirstOrDefault(c => c.Id == model.Id);

            if (categoryEntity != null)
            {
                categoryEntity.Name     = model.Name;
                categoryEntity.CoverUrl = model.CoverUrl;

                await this.dbContext.SaveChangesAsync();
            }
        }
        public async Task <CategoryInputModel> Create(CategoryInputModel model)
        {
            if (this.dbContext.Categories.Any(c => c.Name == model.Name))
            {
                throw new InvalidOperationException("Category already exists!");
            }

            ShopApp.Models.ShopUser user = this.userService.GetUserById(model.CreatorId);

            ShopApp.Models.Category categoryEntity = new ShopApp.Models.Category
            {
                Id        = Guid.NewGuid().ToString(),
                Name      = model.Name,
                CoverUrl  = model.CoverUrl,
                CreatedOn = DateTime.UtcNow,
                CreatorId = user.Id
            };

            this.dbContext.Categories.Add(categoryEntity);
            await this.dbContext.SaveChangesAsync();

            return(model);
        }