public IActionResult EnterQuote(QuoteList newQuote) { context.QuoteLists.Add(newQuote); context.SaveChanges(); return(RedirectToAction("Index", newQuote)); }
public AIA.Life.Models.Opportunity.QuoteList GetReason(string Decision) { ProspectLogic objlogic = new ProspectLogic(); QuoteList objQuoteList = new QuoteList(); objQuoteList = objlogic.GetReason(Decision); return(objQuoteList); }
public AIA.Life.Models.Opportunity.QuoteList GetReason(string Decision) { QuoteList objQuoteList = new QuoteList(); AIA.Life.Business.Prospect.ProspectBusiness objProspectBusiness = new AIA.Life.Business.Prospect.ProspectBusiness(); objQuoteList = objProspectBusiness.GetReason(Decision); return(objQuoteList); }
public AIA.Life.Models.Opportunity.QuoteList GetVariant(string Plan) { QuoteList objQuoteList = new QuoteList(); AIA.Life.Business.Prospect.ProspectBusiness objProspectBusiness = new AIA.Life.Business.Prospect.ProspectBusiness(); objQuoteList = objProspectBusiness.GetVariant(Plan); return(objQuoteList); }
public AIA.Life.Models.Opportunity.QuoteList GetVariant(string Plan) { #region Call API QuoteList objQuoteList = new QuoteList(); objQuoteList = WebApiLogic.GetPostParametersToAPI <AIA.Life.Models.Opportunity.QuoteList>(objQuoteList, "Suspect", "GetVariant", "Plan", Plan); #endregion return(objQuoteList); }
public AIA.Life.Models.Opportunity.QuoteList GetReason(string Decision) { #region Call API QuoteList objQuoteList = new QuoteList(); objQuoteList = WebApiLogic.GetPostParametersToAPI <AIA.Life.Models.Opportunity.QuoteList>(objQuoteList, "Suspect", "GetReason", "Decision", Decision); #endregion return(objQuoteList); }
public AIA.Life.Models.Opportunity.QuoteList GetPlanCode(string Variant) { ProspectLogic objlogic = new ProspectLogic(); QuoteList objQuoteList = new QuoteList(); objQuoteList = objlogic.GetPlanCode(Convert.ToInt32(Variant)); return(objQuoteList); }
public AIA.Life.Models.Opportunity.QuoteList GetVariant(string Plan) { ProspectLogic objlogic = new ProspectLogic(); QuoteList objQuoteList = new QuoteList(); objQuoteList = objlogic.GetVariant(Plan); return(objQuoteList); }
public IActionResult DeleteQuote(int quoteID) { QuoteList quote = context.QuoteLists.First(q => q.QuoteID == quoteID); context.Remove(quote); context.SaveChanges(); return(RedirectToAction("Index")); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var jo = serializer.Deserialize <JObject>(reader); var result = new QuoteList(); result.Quotes = new List <Quote>(); foreach (var prop in jo.Properties()) { var p = prop.Value.ToObject <Quote>(); // set name from property name p.symbol = prop.Name; result.Quotes.Add(p); } return(result); }
// GET: Admin public ActionResult Index() { using (CarInsurance db = new CarInsurance()) { var quotes = db.QuoteLists.ToList(); var quotesVms = new List <QuoteList>(); foreach (var newQuote in quotes) { var quoteVm = new QuoteList(); quoteVm.firstName = newQuote.firstName; quoteVm.lastName = newQuote.lastName; quoteVm.emailAddress = newQuote.emailAddress; quoteVm.finalQuote = newQuote.finalQuote; quotesVms.Add(quoteVm); } return(View(quotesVms)); } }
//public QuoteRepository(ISolrOperations<Quote> context) //{ // _ctx = context; //} public QuoteList GetAll() { var quotes = _ctx.Query(SolrQuery.All); var trimmedQuotes = quotes.Select(q => new Quote { Abstract = q.Abstract, ArticleBody = q.ArticleBody.Length < 200 ? q.ArticleBody : q.ArticleBody.Substring(0, 200), Id = q.Id, Source = q.Source, Title = q.Title, Year = q.Year }); var theQuotes = new QuoteList() { Quotes = trimmedQuotes }; return(theQuotes); }
public IActionResult EditQuote(QuoteList curQuote, int quoteID) { var updatedQuote = context.QuoteLists.FirstOrDefault(q => q.QuoteID == quoteID); if (updatedQuote != null && ModelState.IsValid) { updatedQuote.Quote = curQuote.Quote; updatedQuote.Speaker = curQuote.Speaker; updatedQuote.Date = curQuote.Date; updatedQuote.Subject = curQuote.Subject; updatedQuote.Citation = curQuote.Citation; context.SaveChanges(); return(RedirectToAction("Index")); } else { return(View("Index")); } }
delegate void Reflist(JObject ja); /*声明委托*/ private void RefreshQuoteList(JObject jo) { try { var ja = jo["quote10"]; if (this.QuoteList.InvokeRequired) { //为当前控件指定委托 this.QuoteList.Invoke(new Reflist(RefreshQuoteList), jo); } else { QuoteList.BeginUpdate(); QuoteList.Columns[3].Text = (++ref_list1_count).ToString(); double price = double.Parse(ja[0]["昨收"].ToString()); string s = ""; for (int i = 10; i >= 1; i--) { s = ja[0]["卖" + CH_NUM[i] + "价"].ToString(); QuoteList.Items[10 - i].SubItems[1].Text = s.Substring(0, s.IndexOf(".") + 3); QuoteList.Items[10 - i].SubItems[2].Text = ja[0]["卖" + CH_NUM[i] + "量"].ToString(); if (double.Parse(s) > price) { QuoteList.Items[10 - i].SubItems[1].ForeColor = RGB(0x5C5CFF);//blue } else if (double.Parse(s) < price) { QuoteList.Items[10 - i].SubItems[1].ForeColor = RGB(0x65E339); //green } else { QuoteList.Items[10 - i].SubItems[1].ForeColor = Color.White; } QuoteList.Items[10 - i].SubItems[2].ForeColor = Color.White; } for (int i = 1; i <= 10; i++) { s = ja[0]["买" + CH_NUM[i] + "价"].ToString(); QuoteList.Items[10 + i].SubItems[1].Text = s.Substring(0, s.IndexOf(".") + 3); QuoteList.Items[10 + i].SubItems[2].Text = ja[0]["买" + CH_NUM[i] + "量"].ToString(); if (double.Parse(s) > price) { QuoteList.Items[10 + i].SubItems[1].ForeColor = RGB(0x5C5CFF);//blue } else if (double.Parse(s) < price) { QuoteList.Items[10 + i].SubItems[1].ForeColor = RGB(0x65E339);//green } else { QuoteList.Items[10 + i].SubItems[1].ForeColor = Color.White; } QuoteList.Items[10 + i].SubItems[2].ForeColor = Color.White; } } QuoteList.EndUpdate(); } catch { //MessageBox.Show(e.ToString()); return; } }
public IActionResult EditQuote(int quoteID) { QuoteList quote = context.QuoteLists.First(q => q.QuoteID == quoteID); return(View(quote)); }
public ActionResult Quote(string firstName, string lastName, string emailAddress, DateTime DOB, string carYear, string carMake, string carModel, bool DUI, int speedTickets, bool fullCoverage, decimal completedQuote = 50) { if (string.IsNullOrEmpty(firstName) || string.IsNullOrEmpty(lastName) || string.IsNullOrEmpty(emailAddress) || string.IsNullOrEmpty(carYear) || string.IsNullOrEmpty(carModel) || speedTickets < 0) { return(View("~/Views/Shared/Error.cshtml")); } else { using (AutoQuotesEntities db = new AutoQuotesEntities()) { var quote = new QuoteList(); quote.firstName = firstName; quote.lastName = lastName; quote.emailAddress = emailAddress; quote.DOB = DOB; quote.carYear = Convert.ToInt16(carYear); quote.carMake = carMake; quote.carModel = carModel; quote.DUI = DUI; quote.speedTickets = Convert.ToInt16(speedTickets); quote.fullCoverage = fullCoverage; int age = DOB.Year; int month = DOB.Month; int day = DOB.Day; if (DateTime.Now.Month > month) { age = age + 1; } else if (DateTime.Now.Month == month && DateTime.Now.Day >= day) { age = age + 1; } if (DateTime.Now.Year - age < 18) { completedQuote = completedQuote + 100; } else if (DateTime.Now.Year - age < 25) { completedQuote = completedQuote + 25; } else if (DateTime.Now.Year - age > 100) { completedQuote = completedQuote + 25; } int year = Convert.ToInt16(carYear); if (year < 2000) { completedQuote = completedQuote + 25; } else if (year > 2015) { completedQuote = completedQuote + 25; } carMake = carMake.ToLower(); carModel = carModel.ToLower(); if (carMake == "porsche") { completedQuote = completedQuote + 25; } if (carMake == "porsche" && carModel == "911 carrera") { completedQuote = completedQuote + 25; } completedQuote = completedQuote + 10 * speedTickets; if (DUI == true) { completedQuote = (completedQuote * 5) / 4; } if (fullCoverage == true) { completedQuote = (completedQuote * 3) / 2; } quote.completedQuote = Convert.ToInt16(completedQuote); db.QuoteLists.Add(quote); db.SaveChanges(); } return(View("Success")); } }
public void enumerator_Works() { var collection = CreateIDates(0, 1, 2).ToArray(); var sut = new QuoteList<IDate>(collection.AsReadOnlyList()); Assert.True(collection.SequenceEqual(sut), "enumerator does not work."); }
private async void callCurrentQuotes() { quotes.Clear(); using (HttpClient client = new HttpClient()) try { string url = App.base_url + "currentQuotes"; Loader.IsVisible = true; Loader.IsRunning = true; HttpResponseMessage message = await client.GetAsync(url); Loader.IsRunning = false; Loader.IsVisible = false; if (message.StatusCode == HttpStatusCode.OK) { string jsonParsed = await message.Content.ReadAsStringAsync(); QuoteList r = JsonConvert.DeserializeObject <QuoteList>(jsonParsed); string FinalRes = ""; for (int i = 0; i < r.results.Count; i++) { r.results[i].currentInfo = r.results[i].lastPrice + " USD"; r.results[i].changeInfo = r.results[i].percentChange + "%"; double percentChange = r.results[i].percentChange; if (percentChange < 0) { r.results[i].color = "RED"; } else if (percentChange > 0) { r.results[i].color = "GREEN"; } else { r.results[i].color = "GRAY"; } string symbol = r.results[i].symbol; if (symbol.Equals("AAPL")) { r.results[i].companyName = "Apple"; r.results[i].image = "apple_logo.jpg"; } else if (symbol.Equals("IBM")) { r.results[i].companyName = "IBM"; r.results[i].image = "ibm_logo.png"; } else if (symbol.Equals("HPE")) { r.results[i].companyName = "Hewlett Packard"; r.results[i].image = "hp_logo.jpg"; } else if (symbol.Equals("MSFT")) { r.results[i].companyName = "Microsoft"; r.results[i].image = "microsoft_logo.jpg"; } else if (symbol.Equals("ORCL")) { r.results[i].companyName = "Oracle"; r.results[i].image = "oracle_logo.jpg"; } else if (symbol.Equals("GOOGL")) { r.results[i].companyName = "Google"; r.results[i].image = "google_logo.png"; } else if (symbol.Equals("FB")) { r.results[i].companyName = "Facebook"; r.results[i].image = "facebook_logo.png"; } else if (symbol.Equals("TWTR")) { r.results[i].companyName = "Twitter"; r.results[i].image = "twitter_logo.png"; } else if (symbol.Equals("INTC")) { r.results[i].companyName = "Intel"; r.results[i].image = "intel_logo.png"; } else if (symbol.Equals("AMD")) { r.results[i].companyName = "AMD"; r.results[i].image = "amd_logo.jpg"; } quotes.Add(r.results[i]); FinalRes += r.results[i].name + "-" + r.results[i].percentChange + "\n"; } } else { await DisplayAlert("Error", "Some error occurred.(" + message.StatusCode + ")", "Ok"); } } catch (Exception ex) { await DisplayAlert("Error", ex.Message, "Ok"); } btUpdate.IsVisible = true; btUpdate.IsEnabled = true; }
public void From_IsFirst(QuoteList<IDate> sut) { Assert.Equal<DateTime>(sut[0].Date, sut.From); }
public void indexer_Works() { var collection = CreateIDates(0, 1, 2).ToArray(); var sut = new QuoteList<IDate>(collection.AsReadOnlyList()); Assert.True(collection.SequenceEqual(sut.GetIEnumerableThroughIndexing()), "indexer does not work."); }
public void To_IsLast(QuoteList<IDate> sut) { Assert.Equal<DateTime>(sut[sut.Count-1].Date, sut.To); }
public void To_IsLatest(QuoteList<IDate> sut) { Assert.Equal<DateTime>(sut.Max(q => q.Date), sut.To); }
public ActionResult Quote(string firstName, string lastName, string emailAddress, DateTime dateOfBirth, int carYear, string carMake, string carModel, bool DUI, int speedingTickets, bool fullCoverage, decimal finalQuote = 50) { if (string.IsNullOrEmpty(firstName) || string.IsNullOrEmpty(lastName) || string.IsNullOrEmpty(emailAddress) || dateOfBirth == null || carYear == 0 || string.IsNullOrEmpty(carMake) || string.IsNullOrEmpty(carModel) || speedingTickets < 0) { return(View("~/Views/Shared/Error.cshtml")); } else { using (CarInsurance db = new CarInsurance()) { var newQuote = new QuoteList(); newQuote.firstName = firstName; newQuote.lastName = lastName; newQuote.emailAddress = emailAddress; newQuote.dateOfBirth = dateOfBirth; newQuote.carYear = Convert.ToInt16(carYear); newQuote.carMake = carMake; newQuote.carModel = carModel; newQuote.fullCoverage = fullCoverage; newQuote.DUI = DUI; newQuote.speedingTickets = Convert.ToInt16(speedingTickets); int age = dateOfBirth.Year; int month = dateOfBirth.Month; int day = dateOfBirth.Day; if (DateTime.Now.Month > month) { age = age + 1; } else if (DateTime.Now.Month == month && DateTime.Now.Day >= day) { age = age + 1; } if (DateTime.Now.Year - age < 18) { finalQuote = finalQuote + 100; } else if (DateTime.Now.Year - age < 25) { finalQuote = finalQuote + 25; } else if (DateTime.Now.Year - age > 100) { finalQuote = finalQuote + 25; } int year = Convert.ToInt16(carYear); if (year < 2000) { finalQuote = finalQuote + 25; } carMake = carMake.ToLower(); carModel = carModel.ToLower(); if (carMake == "porsche") { finalQuote = finalQuote + 25; } if (carMake == "porsche" && carModel == "911 carerra") { finalQuote = finalQuote + 25; } finalQuote = finalQuote + 10 * speedingTickets; if (DUI == true) { finalQuote = (finalQuote * 5) / 4; } if (fullCoverage == true) { finalQuote = (finalQuote * 3) / 2; } newQuote.finalQuote = Convert.ToInt16(finalQuote); db.QuoteLists.Add(Quote); db.SaveChanges(); } return(View("Success")); } }
public void ctor_HasAscOrder(QuoteList<IDate> sut) { Assert.True(sut.SequenceEqual(sut.OrderBy(q => q.Date))); }
public static decimal calculate_pl(decimal OpenPrice, decimal Amount, string orderType, string instrument, QuoteList quotes) { decimal retPL = decimal.Zero; decimal ClosePrice = decimal.Zero; string mBaseCurrency = instrument.Substring(0, 3); //string mQuoteCurrency = instrument.Substring(3, 3); //calculate P/L try { if (quotes.ContainsKey(instrument)) { decimal conversionRate = 1; if (orderType.Equals(TradePosition.ORDER_TYPE_BUY)) { ClosePrice = quotes[instrument].Bid; if (mBaseCurrency != "USD") { conversionRate = quotes[mBaseCurrency + "USD"].Bid; } retPL = (ClosePrice - OpenPrice) * conversionRate * quotes[instrument].LotSize * Amount; } else { ClosePrice = quotes[instrument].Ask; if (mBaseCurrency != "USD") { conversionRate = quotes[mBaseCurrency + "USD"].Ask; } retPL = (OpenPrice - ClosePrice) * conversionRate * quotes[instrument].LotSize * Amount; } } } catch (Exception ex) { log.Error(ex.Message, ex); retPL = 0; } return(retPL); }
public QuoteForm(Form fm) { mMainForm = (MainForm)fm; InitializeComponent(); /*开启双缓冲*/ QuoteList.DoubleBuffering(true); TransactionDetailList.DoubleBuffering(true); TransactionList.DoubleBuffering(true); this.AutoScaleMode = AutoScaleMode.None; this.AutoSize = false; this.QuoteList.Columns.Add("", 40); this.QuoteList.Columns.Add("价格", 50); this.QuoteList.Columns.Add("数量", 50); this.QuoteList.Columns.Add("0", 70); // 测试计数器 ListViewItem item = new ListViewItem(); for (int i = 0; i < 10; i++) { item = new ListViewItem("卖" + CH_NUM[10 - i]); item.ForeColor = Color.White; item.UseItemStyleForSubItems = false; item.SubItems.Add(new ListViewItem.ListViewSubItem()); item.SubItems.Add(new ListViewItem.ListViewSubItem()); this.QuoteList.Items.Add(item); } item = new ListViewItem(); item.BackColor = Color.Gray; this.QuoteList.Items.Add(item); for (int i = 1; i <= 10; i++) { item = new ListViewItem("买" + CH_NUM[i]); item.ForeColor = Color.White; item.UseItemStyleForSubItems = false; item.SubItems.Add(new ListViewItem.ListViewSubItem()); item.SubItems.Add(new ListViewItem.ListViewSubItem()); this.QuoteList.Items.Add(item); } this.TransactionDetailList.Columns.Add("价格", 40); this.TransactionDetailList.Columns.Add("数量", 35); this.TransactionDetailList.Columns.Add("D", 20); this.TransactionDetailList.Columns.Add("时间", 60); //this.TransactionDetailList.Columns.Add("", 10); for (int i = 0; i < 30; ++i) { item = new ListViewItem(); item.UseItemStyleForSubItems = false; item.SubItems.Add(""); item.SubItems.Add(""); item.SubItems.Add(""); item.SubItems.Add(""); TransactionDetailList.Items.Add(item); } this.TransactionList.Columns.Add("价格", 48); this.TransactionList.Columns.Add("数量", 35); this.TransactionList.Columns.Add("时间", 48); this.TransactionList.Columns.Add("C", 24); //this.TransactionList.Columns.Add("", 10); for (int i = 0; i < 30; ++i) { item = new ListViewItem(); item.UseItemStyleForSubItems = false; item.SubItems.Add(""); item.SubItems.Add(""); item.SubItems.Add(""); item.SubItems.Add(""); TransactionList.Items.Add(item); } /* 初始化定时器,定时刷新F2、F3池 */ mTimer = new System.Timers.Timer(1000); mTimer.Elapsed += new ElapsedEventHandler(timer_event_handler); mTimer.AutoReset = true; mTimer.Enabled = true; }
private void OnOfficePositionsUpdateReceived(object sender, BackofficeUpdateEventArgs e) { App.Current.Dispatcher.Invoke((Action) delegate { QuoteList quotes = e.OfficeUpdate.Quotes; Dictionary <string, List <TradePosition> > positions = e.OfficeUpdate.UserPositions; List <OfficeFloatingStatus> floatingStatus = e.OfficeUpdate.FloatingStatus; lock (lockTrades) { _floatingStatus.Clear(); if (floatingStatus.Count > 0) { _floatingStatus.AddRange(floatingStatus); FloatingStatusCollectionView.Refresh(); } if (e.OfficeUpdate.CoverPositions.Count > 0) { int selIndex = OpenCoverTradesCollectionView.CurrentPosition; _coverPositions.Clear(); _coverPositions.AddRange(e.OfficeUpdate.CoverPositions); if (_coverPositions.Count >= selIndex) { OpenCoverTradesCollectionView.MoveCurrentToPosition(selIndex); } } else { _coverPositions.Clear(); } if (positions.Count > 0) { int currentIndexPending = PendingTradesCollectionView.CurrentPosition; int currentIndexOpen = OpenTradesCollectionView.CurrentPosition; List <TradePosition> pendingWithSelectionPreserved = new List <TradePosition>(); OpenTrades.Clear(); foreach (var row in positions) { foreach (var t in row.Value) { t.ClientName = row.Key; t.CurrentPl *= -1.0M; if (t.OrderState.Equals(TradePosition.ORDER_STATE_OPEN)) { OpenTrades.Add(t); } else if (t.OrderState.Equals(TradePosition.ORDER_STATE_REQUOTED)) { continue; } else { if (!PendingTrades.Contains(t)) { pendingWithSelectionPreserved.Add(t); } else { TradePosition trade = PendingTrades.First(x => x.Equals(t)); t.IsSelected = trade.IsSelected; t.RequotePrice = trade.RequotePrice; t.RequotePriceSet = trade.RequotePriceSet; pendingWithSelectionPreserved.Add(t); } } } } PendingTrades.Clear(); PendingTrades.AddRange(pendingWithSelectionPreserved); if (PendingTradesCollectionView.Count >= currentIndexPending) { PendingTradesCollectionView.MoveCurrentToPosition(currentIndexPending); } if (OpenTradesCollectionView.Count >= currentIndexOpen) { OpenTradesCollectionView.MoveCurrentToPosition(currentIndexOpen); } } else { OpenTrades.Clear(); PendingTrades.Clear(); } } PendingTradesCollectionView.Refresh(); OpenTradesCollectionView.Refresh(); }); }
public void From_IsEarliest(QuoteList<IDate> sut) { Assert.Equal<DateTime>(sut.Min(q => q.Date), sut.From); }