public IHttpActionResult Update(string sessionKey, int id, CategoryModel categoryModel)
        {
            if (!this.ModelState.IsValid)
            {
                return this.BadRequest(this.ModelState);
            }

            var existingCategory = this.GetCategoryById(id);

            if (existingCategory == null)
            {
                return BadRequest("No category with such id exists.");
            }

            var currentUser = this.GetUserBySessionKey(sessionKey);

            if (currentUser == null)
            {
                return BadRequest("Unauthorized access.");
            }

            existingCategory.Name = categoryModel.Name;
            this.data.SaveChanges();

            return Ok(categoryModel);
        }
        public IHttpActionResult Create(string sessionKey, CategoryModel categoryModel)
        {
            if (!this.ModelState.IsValid)
            {
                return this.BadRequest(this.ModelState);
            }

            var currentUser = this.GetUserBySessionKey(sessionKey);

            if (currentUser == null)
            {
                return BadRequest("Unauthorized access.");
            }

            var newCategory = toCategoryEntity(categoryModel);
            newCategory.UserId = currentUser.UserId;

            this.data.Categories.Add(newCategory);
            this.data.SaveChanges();

            categoryModel.CategoryId = newCategory.CategoryId;

            return Ok(categoryModel);
        }