/// <summary> /// 添加【---事务---】 /// </summary> /// <param name="dep"></param> /// <returns></returns> public static int AddStocks(QuotePrice dep, List <QuotePriceDetail> list) { PSSEntities db = new PSSEntities(); int fg = 1; using (var tx = db.Database.BeginTransaction()) { try { db.QuotePrice.Add(dep); if (list != null) { db.QuotePriceDetail.AddRange(list); } db.SaveChanges(); tx.Commit(); } catch (Exception e) { fg = 0; tx.Rollback(); throw new Exception(e.Message); } } return(fg); }
/// <summary> /// 修改【---事务---】 /// </summary> /// <param name="dp"></param> /// <returns></returns> public static int EdiStocks(QuotePrice dep, List <QuotePriceDetail> list) { PSSEntities db = new PSSEntities(); int fg = 1; ///以下开始事务操作 using (var tx = db.Database.BeginTransaction()) { try { //将要修改的创建人找回来,避免修改时没有创建人 QuotePrice st = db.QuotePrice.FirstOrDefault(p => p.QPID == dep.QPID); st.CusID = dep.CusID; st.QPDate = dep.QPDate; st.QPDesc = dep.QPDesc; db.QuotePriceDetail.RemoveRange(db.QuotePriceDetail.Where(p => p.QPID == dep.QPID)); if (list != null) { db.QuotePriceDetail.AddRange(list); } db.SaveChanges(); tx.Commit(); } catch (Exception e) { fg = 0; tx.Rollback(); throw new Exception(e.Message); } } return(fg); }
public static async Task <QuotePrice> GetPriceAsync(string symbol) { try { var csvData = await GetRawAsync(symbol).ConfigureAwait(false); if (csvData != null) { var yq = await Json.ToObjectAsync <YahooQuote>(csvData).ConfigureAwait(false); var quote = yq.quoteResponse.result[0]; var q = new QuotePrice { Symbol = quote.symbol, Exchange = quote.exchange, Timestamp = DateTimeConverter.ToDateTime(quote.regularMarketTime), Close = Math.Round(quote.regularMarketPrice, 3), Open = Math.Round(quote.regularMarketOpen, 3), High = Math.Round(quote.regularMarketDayHigh, 3), Low = Math.Round(quote.regularMarketDayLow, 3), Volume = quote.regularMarketVolume }; return(q); } } catch (Exception ex) { Debug.Print(ex.Message); } return(new QuotePrice()); }
/// <summary> /// 修改报价单 /// </summary> /// <param name="qp"></param> /// <param name="list"></param> /// <returns></returns> public ActionResult EditQuotePrice(QuotePrice qp, List <QuotePriceDetail> list) { if (QuotePriceBLL.EdiStocks(qp, list) > 0) { return(Content("edit_yes")); } else { return(Content("edit_no")); } }
/// <summary> /// 添加报价单 /// </summary> /// <param name="qp"></param> /// <param name="list"></param> /// <returns></returns> public ActionResult AddQuotePrice(QuotePrice qp, List <QuotePriceDetail> list) { qp.UserID = Convert.ToInt32(Session["uid"]); if (QuotePriceBLL.AddStocks(qp, list) > 0) { return(Content("add_yes")); } else { return(Content("add_no")); } }
// // https://query1.finance.yahoo.com/v8/finance/chart/AAPL?interval=2m // https://query1.finance.yahoo.com/v10/finance/quoteSummary/AAPL?modules=assetProfile%2CearningsHistory //https://query1.finance.yahoo.com/v8/finance/chart/AAPL?symbol=AAPL&period1=0&period2=9999999999&interval=1d&includePrePost=true&events=div%2Csplit //https://query1.finance.yahoo.com/v7/finance/quote?symbols=UNP&fields=ebitda,shortRatio,priceToSales //https://query1.finance.yahoo.com/v7/finance/quote?lang=en-US®ion=US&corsDomain=finance.yahoo.com&fields=symbol,longName,shortName,priceHint,regularMarketPrice,regularMarketChange,regularMarketChangePercent,currency,regularMarketTime,regularMarketVolume,quantity,averageDailyVolume3Month,regularMarketDayHigh,regularMarketDayLow,regularMarketPrice,regularMarketOpen,fiftyTwoWeekHigh,fiftyTwoWeekLow,regularMarketPrice,regularMarketOpen,sparkline,marketCap&symbols=000001.SS,600600.SS // https://query1.finance.yahoo.com/v1/finance/search?q=dax"esCount=6&newsCount=0"esQueryId=tss_match_phrase_query&multiQuoteQueryId=multi_quote_single_token_query&enableCb=true //http://d.yimg.com/aq/autoc?query=a®ion=US&lang=en-US&callback=YAHOO.util.ScriptNodeDataSource.callbacks //https://autoc.finance.yahoo.com/autoc?query=PLUG®ion=1&lang=en // https://query1.finance.yahoo.com/v10/finance/quoteSummary/AAPL?modules=assetProfile%2CearningsHistory //https://query1.finance.yahoo.com/v10/finance/quoteSummary/AAPL?modules=defaultKeyStatistics //https://query1.finance.yahoo.com/v10/finance/quoteSummary/AAPL?modules=financialData //https://query1.finance.yahoo.com/v10/finance/quoteSummary/AAPL?modules=assetProfile //https://query1.finance.yahoo.com/v8/finance/chart/AAPL?symbol=AAPL&period1=0&period2=9999999999&interval=1d&includePrePost=true&events=div%2Csplit //https://query1.finance.yahoo.com/v7/finance/quote?formatted=true&crumb=KRXGDVywE2G&lang=de-DE®ion=DE&symbols=FRE.DE%2CFME.DE%2CALV.DE%2CBMW.DE%2CWDI.DE%2CBEI.DE%2CLIN.DE%2CHEI.DE%2CBAYN.DE%2CDBK.DE%2CLHA.DE%2CADS.DE%2C1COV.DE%2CVOW3.DE%2CDTE.DE%2CTKA.DE%2CRWE.DE%2CDPW.DE%2CDB1.DE%2CCON.DE%2CIFX.DE%2CBAS.DE%2CMRK.DE%2CSIE.DE%2CEOAN.DE%2CVNA.DE%2CHEN3.DE%2CMUV2.DE%2CSAP.DE%2CDAI.DE&fields=messageBoardId%2ClongName%2CshortName%2CmarketCap%2CunderlyingSymbol%2CunderlyingExchangeSymbol%2CheadSymbolAsString%2CregularMarketPrice%2CregularMarketChange%2CregularMarketChangePercent%2CregularMarketVolume%2Cuuid%2CregularMarketOpen%2CfiftyTwoWeekLow%2CfiftyTwoWeekHigh&corsDomain=de.finance.yahoo.com public static QuotePrice Price(string Ticker) { WebRequest wrGETURL = WebRequest.Create("https://query1.finance.yahoo.com/v10/finance/quoteSummary/" + Ticker + "?modules=price"); var sss = wrGETURL.GetResponse().ReadToEnd(); try { QuotePrice QP = JsonSerializer.DeserializeFromString <QuotePrice>(sss); return(QP); } catch { return(null); } }
/// <summary> /// 审核采购订单 /// </summary> /// <param name="id"></param> /// <returns></returns> public static int CKInDepot(string id, int userid) { PSSEntities db = new PSSEntities(); int fg = 1; ///以下开始事务操作 using (var tx = db.Database.BeginTransaction()) { try { QuotePrice st = db.QuotePrice.FirstOrDefault(s => s.QPID.Equals(id)); st.QPState = 1; db.SaveChanges(); tx.Commit(); } catch (Exception e) { tx.Rollback(); throw new Exception(e.Message); } } return(fg); }
/// <summary> /// 修改【---事务---】 /// </summary> /// <param name="dp"></param> /// <returns></returns> public static int EdiStocks(QuotePrice dep, List <QuotePriceDetail> list) { return(QuotePriceDAL.EdiStocks(dep, list)); }
public ActionResult Quoter(string firstName, string lastName, string emailAddress, DateTime?dateOfBirth, int carYear, string carMake, string carModel, int?speedingTicketCount, bool?duiCheck, bool?optionCheck) { string dateOfBirthString = dateOfBirth.ToString(); string carYearString = carYear.ToString(); string speedingTicketCountString = speedingTicketCount.ToString(); string duiCheckString = duiCheck.ToString(); string optionCheckString = optionCheck.ToString(); var allStrings = new List <string>() { firstName, lastName, emailAddress, dateOfBirthString, carYearString, carMake, carModel, speedingTicketCountString, duiCheckString, optionCheckString }; foreach (string y in allStrings) { if (string.IsNullOrEmpty(y)) { return(View("~/Shared/Error")); } else { break; } } using (InsuranceDetailsEntities db = new InsuranceDetailsEntities()) { //easy way with ef var quote = new UserDetail(); quote.FirstName = firstName; quote.LastName = lastName; quote.EmailAddress = emailAddress; quote.DateOfBirth = dateOfBirth; quote.CarYear = carYear; quote.CarMake = carMake; quote.CarModel = carModel; quote.SpeedingTicketCount = speedingTicketCount; quote.DUI = duiCheck; quote.Coverage = optionCheck; db.UserDetails.Add(quote); db.SaveChanges(); int linkId = quote.Id; ViewBag.LinkableId = linkId; //declaring int basePrice = 50; int ageAdder; int yearAdder; int carAdder; int ticketAdder; double duiPrice; double coveragePrice; //ticket adder ticketAdder = Convert.ToInt32(quote.SpeedingTicketCount) * 10; //Find age of user and price accordingly int ageAdd1 = 25; int ageAdd2 = 100; DateTime dOB = Convert.ToDateTime(quote.DateOfBirth); int birthYear = dOB.Year; int nowYear = DateTime.Now.Year; int userAge = nowYear - birthYear; if (userAge < 25 && userAge > 18 || userAge > 100) { ageAdder = ageAdd1; } else if (userAge < 18) { ageAdder = ageAdd2; } else { ageAdder = 0; }; //make, year and model adders int modelYearAdd = 25; if (quote.CarYear < 2000 || quote.CarYear > 2015) { yearAdder = modelYearAdd; } else { yearAdder = 0; }; int porscheModifier = 25; int porscheCarreraModifier = porscheModifier * 2; if (quote.CarMake == "Porsche" && quote.CarModel != "911 Carrera") { carAdder = porscheModifier; } else if (quote.CarMake == "Porsche" && quote.CarModel == "911 Carrera") { carAdder = porscheCarreraModifier; } else { carAdder = 0; } double subPrice = Convert.ToDouble(basePrice + ticketAdder + ageAdder + yearAdder + carAdder); if (Convert.ToBoolean(quote.DUI)) { duiPrice = subPrice * .25; } else { duiPrice = 0; } if (Convert.ToBoolean(quote.Coverage)) { coveragePrice = subPrice * .5; } else { coveragePrice = 0; } double totalPrice = subPrice + coveragePrice + duiPrice; var price = new QuotePrice(); price.Id = quote.Id; price.BasePrice = basePrice; price.AgeAdder = ageAdder; price.YearAdder = yearAdder; price.CarAdder = carAdder; price.TicketAdder = ticketAdder; price.DUIPrice = duiPrice; price.CoveragePrice = coveragePrice; price.TotalPrice = totalPrice; db.QuotePrices.Add(price); db.SaveChanges(); } return(View("FinishedQuote")); }