public ActionResult AddCategoryPost(Category model)
 {
     int categoryId = this.categoryRepository.Save(new Category { Name = model.Name});
     if (categoryId > 0)
     {
         ViewBag.Message = "The category was successfully created.";
         return RedirectToAction("GetCategories");
     }
     return View();
 }
 public HttpResponseMessage Post(Category category)
 {
     if (ModelState.IsValid)
     {
         categoryRepository.Save(category);
         HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, category);
         response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = category.CategoryId }));
         return response;
     }
     else
     {
         return Request.CreateResponse(HttpStatusCode.BadRequest);
     }
 }
 public ActionResult EditCategoryPost(Category category)
 {
     int result = this.categoryRepository.Save(category);
     if (result > 0)
     {
         ViewBag.Message = "The record is successfully edited.";
         return RedirectToAction("GetCategories");
     }
     return View();
 }
        public HttpResponseMessage Delete(Category category)
        {
            if (category == null)
            {
                return Request.CreateResponse(HttpStatusCode.NotFound);
            }

            try
            {
                this.categoryRepository.Delete(category.CategoryId);
            }
            catch (Exception ex)
            {
                return Request.CreateResponse(HttpStatusCode.NotFound);
            }

            return Request.CreateResponse(HttpStatusCode.OK, category);
        }