static void Main(string[] args) { var store = new PricingDataAccess("data source=LAPTOP-F0TL3ONH;initial catalog=Examples;integrated security=True;MultipleActiveResultSets=True;"); //var loginData = new Login() { Username = "******", Password = "******" }; var engine = new BasicPricingEngine(); var doc = new PricingDocument(); doc.Request = new PricingRequest(); doc.Request.MainLimit = 2000000L; doc.Request.MainRetention = 1500000L; doc.Request.ExecutionType = "Simple"; try { //store.StoreData(loginData); //loginData = store.LoadData(loginData); //Console.WriteLine(string.Format("Login for {0} stored successfully", loginData.Username)); engine.Calculate(doc); Console.WriteLine("Priced successfully"); store.StoreData(doc); Console.WriteLine("Stored successfully"); } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.ReadKey(); }
public PricingDocument Post([FromBody] PricingDocument value) { try { engine.Calculate(value); dataAccess.StoreData(value); return(value); } catch (Exception ex) { // TODO: ... value.Error = ex.Message; return(value); } }
public void Calculate(PricingDocument Document) { var rndTime = ThreadSafeRandom.Next(1, 5) * 1000; // Random time between 1 and 5 seconds var rndResults = ThreadSafeRandom.Next(5, 20); // Random number of results var count = 0; Enumerable.Range(1, rndResults).ToList().ForEach(x => { Document.Response.Add(new PricingResponse() { ReferenceDate = DateTime.Today.AddDays(count), BenchmarkOne = ThreadSafeRandom.NextDouble(), BenchmarkTwo = ThreadSafeRandom.NextDouble() }); count++; }); System.Threading.Thread.Sleep(rndTime); }