public IHttpActionResult PostTbCatalog(TbCatalog tbCatalog) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.TbCatalogs.Add(tbCatalog); try { db.SaveChanges(); } catch (DbUpdateException) { if (TbCatalogExists(tbCatalog.id)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = tbCatalog.id }, tbCatalog)); }
public IHttpActionResult PutTbCatalog(int id, TbCatalog tbCatalog) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tbCatalog.id) { return(BadRequest()); } db.Entry(tbCatalog).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!TbCatalogExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetTbCatalog(int id) { TbCatalog tbCatalog = db.TbCatalogs.Find(id); if (tbCatalog == null) { return(NotFound()); } return(Ok(tbCatalog)); }
public IHttpActionResult GetbyName(string name) { TbCatalog tbCatalog = db.TbCatalogs.Where(n => n.name == name).FirstOrDefault(); if (tbCatalog == null) { return(NotFound()); } return(Ok(tbCatalog)); }
public IHttpActionResult DeleteTbCatalog(int id) { TbCatalog tbCatalog = db.TbCatalogs.Find(id); if (tbCatalog == null) { return(NotFound()); } db.TbCatalogs.Remove(tbCatalog); db.SaveChanges(); return(Ok(tbCatalog)); }