public IHttpActionResult PutBrandInfo(int id, Data.BrandInfo brandInfo) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != brandInfo.id) { return(BadRequest()); } db.Entry(brandInfo).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!BrandInfoExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PostBrandInfo(Data.BrandInfo brandInfo) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.BrandInfoes.Add(brandInfo); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = brandInfo.id }, brandInfo)); }
public IHttpActionResult GetBrandInfo(int id) { Data.BrandInfo brandInfo = db.BrandInfoes.Find(id); if (brandInfo == null) { return(NotFound()); } return(Ok(brandInfo)); }
public IHttpActionResult DeleteBrandInfo(int id) { Data.BrandInfo brandInfo = db.BrandInfoes.Find(id); if (brandInfo == null) { return(NotFound()); } db.BrandInfoes.Remove(brandInfo); db.SaveChanges(); return(Ok(brandInfo)); }