protected void Save_Click(object sender, EventArgs e) { try { var portfolioStocks = Session["portfolioStocks"] as List <Stock>; if (portfolioStocks == null) { return; } var newPortfolio = new StockExchangeService.Portfolio { Name = PortfolioName.Text, UserId = HttpContext.Current.User.Identity.Name }; var stockIds = new List <int>(); foreach (var portfolioStock in portfolioStocks) { stockIds.Add(portfolioStock.Id); } newPortfolio.StockIds = stockIds.ToArray(); var service = new StockExchangeService.StockExchangeServiceSoapClient(); var objAuthSoapHeader = WebServiceAuthenticationManager.GetAuthSoapHd(); service.CreatePortfolio(objAuthSoapHeader, newPortfolio); } catch (Exception exception) { throw exception; } }
protected void btnAddStock_Click(object sender, EventArgs e) { try { var service = new StockExchangeService.StockExchangeServiceSoapClient(); var objAuthSoapHeader = WebServiceAuthenticationManager.GetAuthSoapHd(); var allStocks = service.GetAllStock(objAuthSoapHeader).ToList(); var selectedStockCode = ddlAllStocks.SelectedItem; var selectedStock = allStocks.FirstOrDefault(x => x.Code == selectedStockCode.ToString()); if (selectedStock == null) { return; } var portfolioStocks = Session["portfolioStocks"] as List <Stock> ?? new List <Stock>(); if (portfolioStocks.FirstOrDefault(x => x.Code == selectedStock.Code) != null) { return; } portfolioStocks.Add(selectedStock); gdvPortfolioStocks.DataSource = portfolioStocks; gdvPortfolioStocks.DataBind(); Session["portfolioStocks"] = portfolioStocks; } catch (Exception exception) { throw exception; } }
protected void LoadPortfolio_Click(object sender, EventArgs e) { try { var selectedPortfolio = int.Parse(ddlAllPortfolio.SelectedValue); var service = new StockExchangeService.StockExchangeServiceSoapClient(); var objAuthSoapHeader = WebServiceAuthenticationManager.GetAuthSoapHd(); var portfolioDetails = service.GetPortfolioDetails(objAuthSoapHeader, selectedPortfolio); gdvPortfolioStocks.DataSource = portfolioDetails; gdvPortfolioStocks.DataBind(); } catch (Exception exception) { throw exception; } }
private void LoadAllStocks() { try { var service = new StockExchangeService.StockExchangeServiceSoapClient(); var objAuthSoapHeader = WebServiceAuthenticationManager.GetAuthSoapHd(); var allStocks = service.GetAllStock(objAuthSoapHeader); gdvAllStocks.DataSource = allStocks; gdvAllStocks.DataBind(); } catch (Exception exception) { throw exception; } }
private void LoadAllStocks() { try { var service = new StockExchangeService.StockExchangeServiceSoapClient(); var objAuthSoapHeader = WebServiceAuthenticationManager.GetAuthSoapHd(); var allStocks = service.GetAllStock(objAuthSoapHeader).ToList(); ddlAllStocks.DataTextField = "Code"; ddlAllStocks.DataValueField = "Code"; ddlAllStocks.DataSource = allStocks; ddlAllStocks.DataBind(); } catch (Exception exception) { throw exception; } }
private void LoadAllPortfolios() { try { var userName = HttpContext.Current.User.Identity.Name; var service = new StockExchangeService.StockExchangeServiceSoapClient(); var objAuthSoapHeader = WebServiceAuthenticationManager.GetAuthSoapHd(); var allPortfolio = service.GetAllPortfolios(objAuthSoapHeader, userName); ddlAllPortfolio.DataTextField = "Name"; ddlAllPortfolio.DataValueField = "Id"; ddlAllPortfolio.DataSource = allPortfolio; ddlAllPortfolio.DataBind(); } catch (Exception exception) { throw exception; } }
protected void GetStockPrice_Click(object sender, EventArgs e) { try { var service = new StockExchangeService.StockExchangeServiceSoapClient(); var objAuthSoapHeader = WebServiceAuthenticationManager.GetAuthSoapHd(); var stockPrice = service.GetStockPrice(objAuthSoapHeader, StockSymbol.Text); if (stockPrice == double.MinValue) { lblStockPrice.Text = "Invalid stock symbol provided."; } else { lblStockPrice.Text = string.Format("{0} stock is currently trading at price: {1}", StockSymbol.Text, stockPrice.ToString(CultureInfo.InvariantCulture)); } } catch (Exception exception) { throw exception; } }