public IHttpActionResult AddNew(AdvancedCategoryModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.BadRequest(this.ModelState));
            }

            try
            {
                var category = this.Mapper.Map <QuizCategory>(model);
                this.categories.Create(category);

                return(this.Created($"/api/GetByPattern?pattern={category.Name}", new { id = category.Id }));
            }
            catch (CategoryManagementException ex)
            {
                return(this.BadRequest(ex.Message));
            }
        }
        public IHttpActionResult AddNew(AdvancedCategoryModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return this.BadRequest(this.ModelState);
            }

            try
            {
                var category = this.Mapper.Map<QuizCategory>(model);
                this.categories.Create(category);

                return this.Created($"/api/GetByPattern?pattern={category.Name}", new { id = category.Id });
            }
            catch (CategoryManagementException ex)
            {
                return this.BadRequest(ex.Message);
            }
        }
        public IHttpActionResult Edit(AdvancedCategoryModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.BadRequest(this.ModelState));
            }

            var category = this.categories.GetById(model.Id);

            if (category == null)
            {
                return(this.NotFound());
            }

            this.Mapper.Map(model, category);
            this.categories.Save();

            return(this.Ok());
        }
        public IHttpActionResult Edit(AdvancedCategoryModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return this.BadRequest(this.ModelState);
            }

            var category = this.categories.GetById(model.Id);
            if (category == null)
            {
                return this.NotFound();
            }

            this.Mapper.Map(model, category);
            this.categories.Save();

            return this.Ok();
        }