// PUT api/<controller>/5 public IHttpActionResult Put(SubCategory subCategory) { IHttpActionResult result = null; SubCategoryService service = new SubCategoryService(); if (service.GetSubCategory(subCategory.ID) != null) { service.UpdateSubCategory(subCategory); result = Ok(subCategory); } else { result = NotFound(); } return(result); }
// GET api/<controller>/5 public IHttpActionResult Get(int id) { IHttpActionResult result = null; SubCategoryService service = new SubCategoryService(); SubCategory subCategory = service.GetSubCategory(id); if (subCategory != null) { result = Ok(subCategory); } else { result = NotFound(); } return(result); }
// DELETE api/<controller>/5 public IHttpActionResult Delete(int id) { IHttpActionResult result = null; SubCategoryService service = new SubCategoryService(); SubCategory subCategory = service.GetSubCategory(id); if (subCategory != null) { service.RemoveSubCategory(id); result = Ok(true); } else { result = NotFound(); } return(result); }