示例#1
0
        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));
        }
示例#2
0
        public IHttpActionResult GetPorfolioStock(int id)
        {
            PorfolioStock porfolioStock = db.PorfolioStocks.Find(id);

            if (porfolioStock == null)
            {
                return(NotFound());
            }

            return(Ok(porfolioStock));
        }
示例#3
0
        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));
        }
示例#4
0
        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));
        }