public IHttpActionResult PostCustomerCategory(Models.CustomerCategory customerCategory) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.CustomerCategory.Add(customerCategory); try { db.SaveChanges(); } catch (DbUpdateException) { if (CustomerCategoryExists(customerCategory.IdCategory)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = customerCategory.IdCategory }, customerCategory)); }
public IHttpActionResult PutCustomerCategory(string id, Models.CustomerCategory customerCategory) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != customerCategory.IdCategory) { return(BadRequest()); } db.Entry(customerCategory).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CustomerCategoryExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetCustomerCategory(string id) { Models.CustomerCategory customerCategory = db.CustomerCategory.Find(id); if (customerCategory == null) { return(NotFound()); } return(Ok(customerCategory)); }
public IHttpActionResult DeleteCustomerCategory(string id) { Models.CustomerCategory customerCategory = db.CustomerCategory.Find(id); if (customerCategory == null) { return(NotFound()); } db.CustomerCategory.Remove(customerCategory); db.SaveChanges(); return(Ok(customerCategory)); }