public async Task <IHttpActionResult> PutCategory_SubCategory(int id, Category_SubCategory category_SubCategory) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != category_SubCategory.Id) { return(BadRequest()); } db.Entry(category_SubCategory).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!Category_SubCategoryExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GetCategory_SubCategory(int id) { Category_SubCategory category_SubCategory = await db.Category_SubCategory.FindAsync(id); if (category_SubCategory == null) { return(NotFound()); } return(Ok(category_SubCategory)); }
public async Task <IHttpActionResult> PostCategory_SubCategory(Category_SubCategory category_SubCategory) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Category_SubCategory.Add(category_SubCategory); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = category_SubCategory.Id }, category_SubCategory)); }
public async Task <IHttpActionResult> DeleteCategory_SubCategory(int id) { Category_SubCategory category_SubCategory = await db.Category_SubCategory.FindAsync(id); if (category_SubCategory == null) { return(NotFound()); } db.Category_SubCategory.Remove(category_SubCategory); await db.SaveChangesAsync(); return(Ok(category_SubCategory)); }
public void AddCategory_Subcategory(Category_SubCategory entity) { db.Category_SubCategory.Add(entity); db.SaveChanges(); }