internal async Task <SummaryVM[]> GetSummaryVMAsync(List <int> shoppingCart) { var q = shoppingCart .OrderBy(p => p) .ToArray(); List <SummaryVM> myList = new List <SummaryVM>(); int LastID = 0; SummaryVM tempSum = new SummaryVM(); foreach (int item in q) { if (item != LastID) { Product tempProd = await GetProductByIDAsync(item); tempSum = new SummaryVM { Id = tempProd.Id, Name = tempProd.Name, Price = tempProd.Price, TempPrice = tempProd.TempPrice, Quantity = 1 }; LastID = tempSum.Id; myList.Add(tempSum); } else { tempSum.Quantity++; } } ; return(myList.ToArray()); }
protected override void OnBindingContextChanged() { base.OnBindingContextChanged(); card.BackgroundColor = Color.FromHex(BGColour); var tap = new TapGestureRecognizer(); tap.Tapped += (s, e) => { var args = new BuyRoundArgs() { Group = (GroupDto)this.BindingContext }; SummaryVM.OnBuyCommandExecuted(args); }; card.GestureRecognizers.Add(tap); if (BindingContext != null && ((GroupDto)BindingContext).WhoseShout != null && !String.IsNullOrEmpty(((GroupDto)BindingContext).WhoseShout.AvatarUrl)) { initials.IsVisible = false; } //WebImage.Source = Settings.Current.AvatarUrl; //circle2.Source = Settings.Current.AvatarUrl; //Random r = new Random(); //if (r.Next(2) % 2 == 0) //{ // categoryImage.Source = "ic_food_croissant_white_48dp.png"; //} //BuyRound.Clicked += BuyRound_Clicked; }
// GET: Summary public ActionResult Index() { SummaryVM vm = new SummaryVM(); vm.SessionCount = (int)Session["counter"]; vm.ApplicationCount = (int)HttpContext.Application["counter"]; return(View(vm)); }
//var request = new OAuth2Request("GET", new Uri("https://graph.facebook.com/me?fields=email,first_name,last_name,gender,picture.type(large)"), null, account); private async void AlreadyLoggedIn(FbAccessToken token) { var res = await m_AuthenticationService.HandleAlreadyLoggedIn(token); if (res) { await AuthenticationSuccess(); await Rg.Plugins.Popup.Services.PopupNavigation.Instance.PopAllAsync(); SummaryVM.OnRefreshCommand(); } else { IsLoggingIn = false; } }
public ActionResult SummaryEdit(SummaryVM model) { model.ViewHelper.BindModel(); if (!model.ViewHelper.Validate()) { model.ViewHelper.ReturnErrorMessage = "Please validate all fields before saving."; return(RedirectToAction("Manage", new { caseID = model.ID.Value, tabIndex = 0 })); } try { repository.SaveCaseManagementSummary(model); return(RedirectToAction("Manage", new { caseID = model.ID.Value, tabIndex = 0 })); } catch { model.ViewHelper.ReturnErrorMessage = "We encountered an unexpected problem while saving. Please try again or contact your administrator if the problem persists."; return(RedirectToAction("Manage", new { caseID = model.ID.Value, tabIndex = 0 })); } }
public IActionResult Summary(int PatientId) { var model = new SummaryVM(); if (User.IsInRole("Patient")) { PatientId = _userManager.Users.First(b => b.UserName == User.Identity.Name).PatientId.Value; } var user = _context.Patient.FirstOrDefault(u => u.Id == PatientId); model.DOB = user.Dob; model.PatientId = PatientId; model.PatientName = user.FirstName + " " + user.LastName; model.Medications = _context.Medications.Where(m => m.PatientId == PatientId && m.Active && m.Approved).ToList(); model.Problems = _context.Problems.Where(m => m.PatientId == PatientId && m.Active && m.Approved).ToList(); model.Reactions = _context.Reactions.Where(m => m.PatientId == PatientId && m.Approved).ToList(); return(View(model)); }
// GET: Summary public ActionResult Index() { if (!User.Identity.IsAuthenticated) { return(RedirectToAction("Login", "Account")); } SummaryVM sVM = new SummaryVM(); sVM.TotalCValueToday = 0; sVM.TotalSValueToday = 0; sVM.Coins = new List <HoldingVM>(); sVM.Stocks = new List <StockHoldingVM>(); // Build the Coins model List <HoldingVM> cVM = new List <HoldingVM>(); // Build VM List var holdings = db.Holdings.ToList(); var trades = db.Trades.ToList(); //var altCoins = db.AltCoins.ToList(); // Don't need because of globals list //var exch = db.Exchanges.ToList(); // Don't need to get Exchanges table since not displayed in Summary foreach (Holding h in holdings) { AltCoin a = Globals.lAltCoins.FirstOrDefault(x => x.AltCoinID == h.CoinID); // Exchange e = exch.FirstOrDefault(y => y.ExchangeID == h.ExchangeID); HoldingVM hv = new HoldingVM(); hv.HoldingVMID = h.HoldingID; hv.CoinName = a.CoinName; hv.CoinSymbol = a.CoinSymbol; hv.CoinAmount = h.CoinAmount; //hv.ExchangeName = e.ExchangeName; hv.CoinValueUSD = Convert.ToSingle(Globals.CoinToUSDtoday(a.APICode)); // Calculate Average Paid float coinTraded = 0, amtPaid = 0, coinT; float myCostUSD = 0; foreach (Trade t in trades) { if (t.CoinID == h.CoinID) { coinT = t.AmountTraded - t.Commission; coinTraded += coinT; amtPaid += t.PriceUSD * coinT; myCostUSD += t.AmountTraded * t.PriceUSD; } } if (coinTraded > 0) { hv.AveragePaid = (amtPaid / coinTraded).ToString(); } else { hv.AveragePaid = ""; } if (myCostUSD == 0) { hv.CostUSD = ""; } else { hv.CostUSD = myCostUSD.ToString(); } /* * hv.CoinValueBTC = Convert.ToSingle(Globals.CoinToUSDtoday(a.APICode)) / Convert.ToSingle(Globals.CoinToUSDtoday("bitcoin")); * hv.Percent1 = Globals.PctChange(a.APICode, 1); * hv.Percent7 = Globals.PctChange(a.APICode, 7); */ hv.PriceToday = hv.CoinAmount * hv.CoinValueUSD; sVM.TotalCValueToday += hv.PriceToday; sVM.Coins.Add(hv); } // Build the Stocks model List <StockHoldingVM> tVM = new List <StockHoldingVM>(); string sPrice = "0"; string sChange = "0"; string sVol = "0"; string sAvgVol = "0"; var stocks = db.StockHoldings.ToList(); var stkTrades = db.StockTrades.ToList(); foreach (StockHolding sh in stocks) { StockHoldingVM shVM = new StockHoldingVM(); shVM.Ticker = sh.Ticker; shVM.NumberShares = sh.NumberShares; shVM.Account = sh.StockAccount; // Calculate average of price paid including commission List <StockTrade> lST = new List <StockTrade>(); lST = stkTrades.Where(x => x.Ticker == sh.Ticker).ToList(); float cost = 0; float nShares = 0; foreach (StockTrade st in lST) { cost += st.Price * st.AmountTraded;// + st.Commission*2; nShares += st.AmountTraded; } shVM.PricePaid = cost / nShares; shVM.Commission = 10; // Get price of stock today using Yahoo using (WebClient web = new WebClient()) { string strURL = string.Format("https://finance.yahoo.com/quote/" + sh.Ticker + "?p=" + sh.Ticker); try { string data = web.DownloadString(strURL); int iStart, iEnd; iStart = data.IndexOf("<!-- react-text: 36 -->") + "<!-- react-text: 36 -->".Length; iEnd = data.IndexOf("<!", iStart); sPrice = data.Substring(iStart, iEnd - iStart); iStart = data.IndexOf("quote-market-notice") - 100; iEnd = data.IndexOf("<!-- react-text: 39 -->", iStart) + "<!-- react-text: 39 -->".Length; if (iEnd < 1000) { iEnd = data.IndexOf("<!-- react-text: 38 -->", iStart) + "<!-- react-text: 38 -->".Length; } iStart = iEnd; iEnd = data.IndexOf(" (", iStart); sChange = data.Substring(iStart, iEnd - iStart); iStart = data.IndexOf("<!-- react-text: 74 -->") + "<!-- react-text: 74 -->".Length; iEnd = data.IndexOf("<!", iStart); sVol = data.Substring(iStart, iEnd - iStart); iStart = data.IndexOf("<!-- react-text: 80 -->") + "<!-- react-text: 80 -->".Length; iEnd = data.IndexOf("<!", iStart); sAvgVol = data.Substring(iStart, iEnd - iStart); } catch { } } if (Globals.IsNumeric(sPrice)) { shVM.PriceToday = Convert.ToSingle(sPrice); } else { shVM.PriceToday = 0; } if (Globals.IsNumeric(sChange)) { shVM.Change = Convert.ToSingle(sChange); } else { shVM.Change = 0; } shVM.ValueToday = nShares * shVM.PriceToday; if (Globals.IsNumeric(sVol)) { shVM.Volume = Convert.ToSingle(sVol); } else { shVM.Volume = 0; } if (Globals.IsNumeric(sAvgVol)) { shVM.AvgVol = Convert.ToSingle(sAvgVol); } else { shVM.AvgVol = 0; } sVM.TotalSValueToday += shVM.ValueToday; sVM.Stocks.Add(shVM); } // DJI and NASDAQ using (WebClient web = new WebClient()) { string strURL = string.Format("https://finance.yahoo.com/quote/^DJI?p=^DJI"); try { string data = web.DownloadString(strURL); int iStart, iEnd; iStart = data.IndexOf("<!-- react-text: 36 -->") + "<!-- react-text: 36 -->".Length; iEnd = data.IndexOf("<!", iStart); sPrice = data.Substring(iStart, iEnd - iStart); iStart = data.IndexOf("quote-market-notice") - 100; iEnd = data.IndexOf("<!-- react-text: 39 -->", iStart) + "<!-- react-text: 39 -->".Length; if (iEnd < 1000) { iEnd = data.IndexOf("<!-- react-text: 38 -->", iStart) + "<!-- react-text: 38 -->".Length; } iStart = iEnd; iEnd = data.IndexOf(" (", iStart); sChange = data.Substring(iStart, iEnd - iStart); sVM.DJI = sPrice; sVM.DJIC = Convert.ToSingle(sChange); strURL = string.Format("https://finance.yahoo.com/quote/^IXIC?p=^IXIC"); data = web.DownloadString(strURL); iStart = data.IndexOf("<!-- react-text: 36 -->") + "<!-- react-text: 36 -->".Length; iEnd = data.IndexOf("<!", iStart); sPrice = data.Substring(iStart, iEnd - iStart); iStart = data.IndexOf("quote-market-notice") - 100; iEnd = data.IndexOf("<!-- react-text: 39 -->", iStart) + "<!-- react-text: 39 -->".Length; if (iEnd < 1000) { iEnd = data.IndexOf("<!-- react-text: 38 -->", iStart) + "<!-- react-text: 38 -->".Length; } iStart = iEnd; iEnd = data.IndexOf(" (", iStart); sChange = data.Substring(iStart, iEnd - iStart); sVM.NAS = sPrice; sVM.NASC = Convert.ToSingle(sChange); } catch { sVM.DJI = "Error"; sVM.DJIC = -1; sVM.NAS = "Error"; sVM.NASC = -1; } } return(View(sVM)); }