예제 #1
0
        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();
        }
예제 #2
0
 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);
 }
예제 #3
0
        public ActionResult Create(SolarSystem solarsystem)
        {
            if (ModelState.IsValid)
            {
                db.SolarSystems.Add(solarsystem);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(solarsystem);
        }
예제 #4
0
 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;
 }
예제 #5
0
 public ActionResult Edit(SolarSystem solarsystem)
 {
     if (ModelState.IsValid)
     {
         db.Entry(solarsystem).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(solarsystem);
 }
예제 #6
0
 public Price LatestPrice(SolarSystem system)
 {
     return Prices.Where(p => p.SolarSystemId == system.Id).OrderByDescending(p => p.Date).First();
 }