public IHttpActionResult CreateCategory(CategoryBindingModel categoryBinding)
        {
            if (categoryBinding == null)
            {
                return this.BadRequest("Input is empty.");
            }

            if (!this.ModelState.IsValid)
            {
                return this.BadRequest(this.ModelState);
            }

            if (this.Data.Categories.Read().Any(c => c.Name == categoryBinding.Name))
            {
                return this.BadRequest("Duplicate category name");
            }

            var category = new Category { Name = categoryBinding.Name };

            this.Data.Categories.Create(category);
            this.Data.SaveChanges();

            var categoryView = new CategoryViewModel
                                   {
                                       Id = category.Id, 
                                       Name = category.Name
                                   };

            return this.Ok(categoryView);
        }
        public IHttpActionResult UpdateCategory(int id, CategoryBindingModel categoryBinding)
        {
            var category = this.Data.Categories.Read().FirstOrDefault(c => c.Id == id);

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

            if (categoryBinding == null)
            {
                return this.BadRequest("Input is empty.");
            }

            if (!this.ModelState.IsValid)
            {
                return this.BadRequest(this.ModelState);
            }

            if (this.Data.Categories.Read().Any(c => c.Name == categoryBinding.Name && c.Id != id))
            {
                return this.BadRequest("Duplicate category name");
            }

            category.Name = categoryBinding.Name;

            this.Data.Categories.Update(category);
            this.Data.SaveChanges();

            var categoryView = new CategoryViewModel
                                   {
                                       Id = category.Id, 
                                       Name = category.Name
                                   };

            return this.Ok(categoryView);
        }