IEnumerable<Price> IMarketPriceRepository.FetchPrices(IEnumerable<Item> items, SolarSystem system) { string urlData = ""; foreach (Item item in items) { urlData += "typeid=" + item.ApiId + "&"; } urlData += "usesystem=" + system.ApiId; XDocument doc = XDocument.Load(String.Format(String.Format(_priceURL, urlData))); IEnumerable<XElement> itemElements = doc.Element("evec_api").Element("marketstat").Elements("type"); IList<Price> prices = new List<Price>(); foreach (XElement itemElement in itemElements) { string itemApi = itemElement.Attribute("id").Value; Item currentItem = items.Single(i => i.ApiId.Equals(itemApi)); Price price = new Price { Item = currentItem, SolarSystem = system, Buy = Double.Parse(itemElement.Element("buy").Element("max").Value, CultureInfo.InvariantCulture), Sell = Double.Parse(itemElement.Element("sell").Element("min").Value, CultureInfo.InvariantCulture), Date = DateTime.Today }; prices.Add(price); } return prices.AsEnumerable(); }
public JsonResult AjaxCreate(int ApiId) { mapSolarSystem eveSolar = EveContext.mapSolarSystems.SingleOrDefault(x => x.solarSystemID == ApiId); SolarSystem solarSystem = new SolarSystem(); solarSystem.Name = eveSolar.solarSystemName; solarSystem.ApiId = eveSolar.solarSystemID.ToString(); db.SolarSystems.Add(solarSystem); db.SaveChanges(); return Json(solarSystem, JsonRequestBehavior.AllowGet); }
public ActionResult Create(SolarSystem solarsystem) { if (ModelState.IsValid) { db.SolarSystems.Add(solarsystem); db.SaveChanges(); return RedirectToAction("Index"); } return View(solarsystem); }
Price IMarketPriceRepository.FetchPrice(Item item, SolarSystem system) { string urlData = String.Format("typeid={0}&usesystem={1}", item.ApiId, system.ApiId); XDocument doc = XDocument.Load(String.Format(_priceURL, urlData)); XElement itemElement = doc.Element("evec_api").Element("marketstat").Elements("type").First(); Price price = new Price { Item = item, SolarSystem = system, Buy = Double.Parse(itemElement.Element("buy").Element("max").Value, CultureInfo.InvariantCulture), Sell = Double.Parse(itemElement.Element("sell").Element("min").Value, CultureInfo.InvariantCulture), Date = DateTime.Today }; return price; }
public ActionResult Edit(SolarSystem solarsystem) { if (ModelState.IsValid) { db.Entry(solarsystem).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(solarsystem); }
public Price LatestPrice(SolarSystem system) { return Prices.Where(p => p.SolarSystemId == system.Id).OrderByDescending(p => p.Date).First(); }