public IHttpActionResult PutPorfolioStock(int id, PorfolioStock porfolioStock) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != porfolioStock.StockId) { return(BadRequest()); } db.Entry(porfolioStock).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PorfolioStockExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetPorfolioStock(int id) { PorfolioStock porfolioStock = db.PorfolioStocks.Find(id); if (porfolioStock == null) { return(NotFound()); } return(Ok(porfolioStock)); }
public IHttpActionResult PostPorfolioStock(PorfolioStock porfolioStock) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.PorfolioStocks.Add(porfolioStock); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = porfolioStock.StockId }, porfolioStock)); }
public IHttpActionResult DeletePorfolioStock(int id) { PorfolioStock porfolioStock = db.PorfolioStocks.Find(id); if (porfolioStock == null) { return(NotFound()); } db.PorfolioStocks.Remove(porfolioStock); db.SaveChanges(); return(Ok(porfolioStock)); }