示例#1
0
        public async Task <ActionResult> Edit(string id, FormCollection collection)
        {
            try
            {
                var ticker           = collection["Ticker"].ToString();
                var tickerPrice      = Convert.ToDouble(collection["Ticker"]);
                var time             = Convert.ToDateTime(collection["Time"]);
                var fundPriceHistory = new FundPriceHistory()
                {
                    Id          = id,
                    Ticker      = ticker,
                    TickerPrice = tickerPrice,
                    Time        = time
                };

                //var fundPriceHistoryName = collection["FundPriceHistoryName"].ToString();
                //var fundPriceHistory = new FundPriceHistory()
                //{
                //    Id = id,
                //    FundPriceHistoryName = fundPriceHistoryName
                //};
                await FundPriceHistoryLib.UpdateFundPriceHistory(fundPriceHistory);

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
示例#2
0
        public async Task <ActionResult> Create(FormCollection collection)
        {
            try
            {
                var rand             = new Random();
                var id               = rand.Next().ToString();
                var ticker           = collection["Ticker"].ToString();
                var tickerPrice      = Convert.ToDouble(collection["Ticker"]);
                var time             = Convert.ToDateTime(collection["Time"]);
                var fundPriceHistory = new FundPriceHistory()
                {
                    Id          = id,
                    Ticker      = ticker,
                    TickerPrice = tickerPrice,
                    Time        = time
                };
                await FundPriceHistoryLib.InsertFundPriceHistory(fundPriceHistory);

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
示例#3
0
        // GET: FundPriceHistory/Edit/5
        public async Task <ActionResult> Edit(string id)
        {
            var fundPriceHistory = await FundPriceHistoryLib.GetFundPriceHistory(id.ToString());

            if (fundPriceHistory == null)
            {
                var errorMsg = string.Format("FundPriceHistory {0} not found.", id);
                throw new HttpException(404, errorMsg);
            }
            return(View(fundPriceHistory));
        }
示例#4
0
        public async Task <ActionResult> Delete(string id, FormCollection collection)
        {
            try
            {
                await FundPriceHistoryLib.DeleteFundPriceHistory(id);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
 //public async void PostAsync([FromBody]string value)
 // In case there is a POST request, to API/Fund, we refresh the fund prices
 public async Task PostAsync()
 {
     var fundLib = new FundPriceHistoryLib();
     await fundLib.RefreshCurrentFundPrices();
 }
示例#6
0
        // GET: FundPriceHistory
        public async Task <ActionResult> Index()
        {
            var fundPriceHistorys = await FundPriceHistoryLib.GetAllFundPriceHistorys();

            return(View(fundPriceHistorys));
        }