public async Task VintageTest() { Vintage data = (await FredClient.GetVintageDates("GNPCA", new DateTime(2020, 1, 1))).FirstOrDefault(); Assert.IsNotNull(data); Assert.IsFalse(String.IsNullOrEmpty(data.Symbol)); Assert.AreNotEqual(DateTime.MinValue, data.VintageDate); }
public PartyViewModel(Vintage.Rabbit.Parties.Entities.Party party) { this.Guid = party.Guid; this.OrderGuid = party.OrderGuid; this.Status = party.Status; this.PartyDate = party.PartyDate; this.HireDate = party.HireDate; this.ReturnDate = party.ReturnDate; this.ChildsName = party.ChildsName; this.Age = party.Age; this.PartyTime = party.PartyTime; this.PartyAddress = party.PartyAddress; this.RSVPDetails = party.RSVPDetails; }
public PartyHireInformationViewModel(Address address, Order order, Vintage.Rabbit.Parties.Entities.Party party) : base(address) { this.DeliveryCost = Constants.HireDeliveryCost.ToString("C0"); this.IsDelivery = order.Items.Any(o => o.Product.Type == ProductType.Delivery && o.Product.Title == "Pickup Hire Delivery") || order.Items.Any(o => o.Product.Type == ProductType.Delivery && o.Product.Title == "Dropoff Hire Delivery"); if(party != null) { this.PartyDate = party.PartyDate; } if (address != null) { this.PhoneNumber = address.PhoneNumber; } }
public IActionResult Rate(RateModel rateModel) { if (ModelState.IsValid) { var alcoholVintage = Context.AlcoholVintages.Where(x => x.AlcoholId == rateModel.AlcoholId) .SingleOrDefault(x => x.Vintage.Year == rateModel.Year); if (alcoholVintage == null) { var alcvintage = new AlcoholVintage(); alcvintage.AlcoholId = rateModel.AlcoholId; var checkVintage = Context.Vintages.SingleOrDefault(x => x.Year == rateModel.Year); if (checkVintage == null) { var vintage = new Vintage() { Year = rateModel.Year }; Context.Vintages.Add(vintage); Context.SaveChanges(); } alcvintage.VintageId = Context.Vintages.SingleOrDefault(x => x.Year == rateModel.Year).Id; Context.AlcoholVintages.Add(alcvintage); Context.SaveChanges(); } var user = Context.Users.Single(x => x.UserName == User.Identity.Name); var userRate = new UserRate() { User = user, AlcoholVintage = Context.AlcoholVintages.Where(x => x.Alcohol.Wine.Name == rateModel.Name) .Single(x => x.Vintage.Year == rateModel.Year), Rating = rateModel.Rating, Comment = rateModel.Comment }; Context.UserRates.Add(userRate); Context.SaveChanges(); return(RedirectToAction("Index", "Wine")); } return(View(rateModel)); }
public InvitationViewModel(Order order, Vintage.Rabbit.Parties.Entities.Party party) { var invitation = order.Items.FirstOrDefault(o => ProductHelper.IsCustomisableInvitation(o.Product)); if(invitation != null && invitation.Product is IProduct && (invitation.Product as IProduct).Images.Any()) { this.InvitationImage = (invitation.Product as IProduct).Images.First().SecureUrl; } if(party != null) { this.ChildsName = party.ChildsName; this.Age = party.Age; this.PartyDate = party.PartyDate; this.PartyTime = party.PartyTime; this.PartyAddress = party.PartyAddress; this.RSVPDetails = party.RSVPDetails; } }
public List <IObservation> MakeDense(List <IObservation> sparse) { List <IObservation> dense = new List <IObservation>(); if (!(sparse?.Any() ?? false)) { return(dense); } foreach (var grp in sparse.GroupBy(x => x.Symbol)) { List <IObservation> sparseGrp = grp.OrderBy(x => x.VintageDate).ThenBy(x => x.ObsDate).ToList(); IVintage vintage = new Vintage { VintageDate = DateTime.MinValue }; Dictionary <DateTime, IObservation> dict = new Dictionary <DateTime, IObservation>(); for (int i = 0; i < sparseGrp.Count; i++) { IObservation o = sparseGrp[i]; if (o.VintageDate != vintage.VintageDate) { CopyDictToDenseObs(vintage, dict, dense); vintage.VintageDate = o.VintageDate; } dict.TryGetValue(o.ObsDate, out IObservation existing); if (existing == null || existing.Value != o.Value) { dict[o.ObsDate] = o; } } CopyDictToDenseObs(vintage, dict, dense); } return(dense); }
static void Main(string[] args) { var bmw = new Modern("BMW", "R1150-RT", 2005); var honda = new Vintage("Honda", "Nighthawk 700SC", 1986); var grassroots = new IPA("Calfkiller", "Grassroots", 5.7, "unknown"); var getUpGetDown = new Stout("Wiseacre", "Gotta Get Up To Get Down", 5, true); var elijah = new Bourbon("Elijah Craig", "Small Batch", "94", "Kentucky"); var balcones = new Bourbon("Balcones", "True Blue", "100", "Texas"); var sarah = new Female("Sarah", "Silverman", "Jesus Is Magic"); var cross = new Male("David", "Cross", "Mr. Show"); Console.WriteLine("These are my current favorite motorcycles:"); Console.WriteLine(bmw.Year + " " + bmw.Make + " " + bmw.Model); Console.WriteLine(honda.Year + " " + honda.Make + " " + honda.Model); Console.WriteLine(""); Console.WriteLine("These are some of my favorite beers:"); Console.WriteLine(grassroots.Brand + " " + grassroots.Name + " is " + grassroots.Abv + "%"); Console.WriteLine(getUpGetDown.Brand + " " + getUpGetDown.Name + " is a " + getUpGetDown.Abv + "%"); Console.WriteLine(""); Console.WriteLine("These are some of my favorite whiskeys:"); Console.WriteLine(elijah.Brand + " " + elijah.Name + " is " + elijah.Proof + " proof"); Console.WriteLine(balcones.Brand + " " + balcones.Name + " is " + balcones.Proof + " proof"); Console.WriteLine(""); Console.WriteLine("These are some of my favorite comedians:"); Console.WriteLine(sarah.FirstName + " " + sarah.LastName + " was awesome in '" + sarah.BestWork + "'"); Console.WriteLine(cross.FirstName + " " + cross.LastName + " was awesome in '" + cross.BestWork + "'"); Console.ReadKey(); }
private List <Vintage> CreateTestData() { List <Vintage> vintages = new List <Vintage>(); vintages.Add(new Vintage { Symbol = "1", VintageDate = new DateTime(2000, 1, 1), Observations = new List <IObservation>() }); vintages.Add(new Vintage { Symbol = "1", VintageDate = new DateTime(2000, 2, 1), Observations = new List <IObservation>() }); vintages.Add(new Vintage { Symbol = "1", VintageDate = new DateTime(2000, 3, 1), Observations = new List <IObservation>() }); Vintage v1 = vintages[0]; v1.Observations.Add(new Observation { VintageDate = v1.VintageDate, Vintage = v1, ObsDate = new DateTime(1999, 1, 1), Value = "1" }); v1.Observations.Add(new Observation { VintageDate = v1.VintageDate, Vintage = v1, ObsDate = new DateTime(1999, 2, 1), Value = "2" }); v1.Observations.Add(new Observation { VintageDate = v1.VintageDate, Vintage = v1, ObsDate = new DateTime(1999, 3, 1), Value = "3" }); Vintage v2 = vintages[1]; v2.Observations.Add(new Observation { VintageDate = v2.VintageDate, Vintage = v2, ObsDate = new DateTime(1999, 1, 1), Value = "1" }); v2.Observations.Add(new Observation { VintageDate = v2.VintageDate, Vintage = v2, ObsDate = new DateTime(1999, 2, 1), Value = "2" }); v2.Observations.Add(new Observation { VintageDate = v2.VintageDate, Vintage = v2, ObsDate = new DateTime(1999, 2, 2), Value = "2.2" }); //Missing in Vintage 1 v2.Observations.Add(new Observation { VintageDate = v2.VintageDate, Vintage = v2, ObsDate = new DateTime(1999, 3, 1), Value = "3.5" }); v2.Observations.Add(new Observation { VintageDate = v2.VintageDate, Vintage = v2, ObsDate = new DateTime(1999, 4, 1), Value = "4" }); Vintage v3 = vintages[2]; v3.Observations.Add(new Observation { VintageDate = v3.VintageDate, Vintage = v3, ObsDate = new DateTime(1999, 1, 1), Value = "1" }); v3.Observations.Add(new Observation { VintageDate = v3.VintageDate, Vintage = v3, ObsDate = new DateTime(1999, 2, 1), Value = "2" }); v3.Observations.Add(new Observation { VintageDate = v3.VintageDate, Vintage = v3, ObsDate = new DateTime(1999, 2, 2), Value = "2.2" }); // must exist here as it cannot be removed v3.Observations.Add(new Observation { VintageDate = v3.VintageDate, Vintage = v3, ObsDate = new DateTime(1999, 3, 1), Value = "3" }); v3.Observations.Add(new Observation { VintageDate = v3.VintageDate, Vintage = v3, ObsDate = new DateTime(1999, 4, 1), Value = "4" }); v3.Observations.Add(new Observation { VintageDate = v3.VintageDate, Vintage = v3, ObsDate = new DateTime(1999, 5, 1), Value = "5" }); return(vintages); }