public JsonResult ReprocessProfit(int itemId, int refiningLevel, int refineryEfficiencyLevel, int scrapProcessingLevel, double standing, int accountingLevel) { IMarketPriceRepository priceRepository = new EveCentralRepository(); SolarSystem system = db.SolarSystems.Single(s => s.Name.Equals("Jita")); Item item = db.Items.Find(itemId); double reprocessPrice = 0; int eveId = Int32.Parse(item.ApiId); foreach(invTypeMaterial material in EveContext.invTypeMaterials.Where(m => m.typeID == eveId)) { string materialId = material.materialTypeID.ToString(); Item requiredItem = db.Items.SingleOrDefault(i => i.ApiId == materialId); if (requiredItem == null) { requiredItem = new Item(); invType type = EveContext.invTypes.SingleOrDefault(t => t.typeID == material.materialTypeID); requiredItem.ApiId = type.typeID.ToString(); requiredItem.Name = type.typeName; db.Items.Add(requiredItem); Price p = priceRepository.FetchPrice(requiredItem, system); db.Prices.Add(p); db.SaveChanges(); } // There's a tax when selling an item but not when buying one (only if not in advanced mode) reprocessPrice += double.Parse(String.Format("{0:0.00}", (requiredItem.LatestPrice(system).Buy * Utils.ReprocessTax(material.quantity, refiningLevel, refineryEfficiencyLevel, scrapProcessingLevel, standing)) * (1 - Utils.SaleTax(accountingLevel)))); } double profit = reprocessPrice - item.LatestPrice(system).Buy; return Json(profit, JsonRequestBehavior.AllowGet); }
public PartialViewResult AjaxCreate(int ApiId) { invType eveItem = EveContext.invTypes.SingleOrDefault(x => x.typeID == ApiId); Item item = new Item(); item.Name = eveItem.typeName; item.ApiId = eveItem.typeID.ToString(); db.Items.Add(item); IMarketPriceRepository priceRepository = new EveCentralRepository(); Price p = priceRepository.FetchPrice(item, db.SolarSystems.Single(s => s.Name.Equals("Jita"))); db.Prices.Add(p); db.SaveChanges(); eveHQDB.UpdatePrice(p, Price.SELL); eveHQDB.SaveChanges(); return PartialView("ItemTableTemplate", item); }
public ActionResult ProfitAnalysis(int solarSystemID, int refiningLevel, int refineryEfficiencyLevel, int scrapProcessingLevel, double standing, int accountingLevel, string buyMode, string sellMode) { IList<ProfitViewModel> profitableItems = new List<ProfitViewModel>(); IMarketPriceRepository priceRepository = new EveCentralRepository(); SolarSystem system = db.SolarSystems.Find(solarSystemID); foreach (Item item in db.Items.ToList<Item>()) { double reprocessPrice = 0; int eveId = Int32.Parse(item.ApiId); foreach (invTypeMaterial material in EveContext.invTypeMaterials.Where(m => m.typeID == eveId)) { string materialId = material.materialTypeID.ToString(); Item requiredItem = db.Items.SingleOrDefault(i => i.ApiId == materialId); if (requiredItem == null) { requiredItem = new Item(); invType type = EveContext.invTypes.SingleOrDefault(t => t.typeID == material.materialTypeID); requiredItem.ApiId = type.typeID.ToString(); requiredItem.Name = type.typeName; db.Items.Add(requiredItem); Price p = priceRepository.FetchPrice(requiredItem, system); db.Prices.Add(p); db.SaveChanges(); } // There's a tax when selling an item but not when buying one (only if not in advanced mode) reprocessPrice += double.Parse(String.Format("{0:0.00}", (requiredItem.LatestPrice(system).GetPrice(sellMode) * Utils.ReprocessTax(material.quantity, refiningLevel, refineryEfficiencyLevel, scrapProcessingLevel, standing)) * (1 - Utils.SaleTax(accountingLevel)))); } double profit = reprocessPrice - item.LatestPrice(system).GetPrice(buyMode); if (profit > 0) { profitableItems.Add(new ProfitViewModel { Item = item, Profit = profit }); } } return View("ProfitAnalysis", profitableItems); }