public IHttpActionResult Updatestockprice(dynamic price)
        {
            PriceHistory history = new PriceHistory();

            history.Isin       = price.isin;
            history.OfferPrice = price.OfferPrice;
            history.Type       = "Stock";
            history.BidPrice   = price.BidPrice;
            history.Date       = DateTime.Now;

            int changeline = PriceHistoryDao.setPriceHistory(history);

            List <Position> positions = PositionDao.getPositionsByIsin(history.Isin);
            Portfolio       portfolio = new Portfolio();
            int             changline = 0;

            foreach (Position p in positions)
            {
                portfolio = PortfolioDao.getPortfoliosById(p.PortfolioId);
                double           pnl         = Getportfoliopnl(portfolio.PortfolioId);
                PortfolioHistory porthistory = new PortfolioHistory();
                porthistory.PNL         = pnl;
                porthistory.Date        = DateTime.Now;
                porthistory.PortfolioId = portfolio.PortfolioId;
                int line = PortfolioHistoryDao.setPortfolioHistory(porthistory);
                changline++;
            }

            return(Ok("success"));
        }
        public IHttpActionResult addPortfolioHistorys(PortfolioHistory c)
        {
            PortfolioHistory c1 = new PortfolioHistory {
                Id = 1, PortfolioId = 1, Date = Convert.ToDateTime("1992-03-20"), PNL = 0.387
            };
            int changeLine = PortfolioHistoryDao.setPortfolioHistory(c);

            return(Ok(changeLine));
        }
Exemplo n.º 3
0
        public IHttpActionResult addPortfolios(Portfolio c)
        {
            int changeLine          = PortfolioDao.addPortfolio(c);
            PortfolioHistory inital = new PortfolioHistory();

            inital.Date        = DateTime.Now;
            inital.PNL         = 0;
            inital.PortfolioId = PortfolioDao.getPortfolioBySomething(c).PortfolioId;
            int addpnlresult = PortfolioHistoryDao.setPortfolioHistory(inital);

            if (changeLine == 1 && addpnlresult == 1)
            {
                return(Ok("Success"));
            }
            return(NotFound());
        }