public async Task <ActionResult> DeleteConfirmed(int id) { RSStock rSStock = await db.Stocks.FindAsync(id); db.Stocks.Remove(rSStock); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit(RSStock rSStock) { if (ModelState.IsValid) { db.Entry(rSStock).State = System.Data.Entity.EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(rSStock)); }
public async Task <ActionResult> Create(RSStock rSStock) { if (ModelState.IsValid) { db.Stocks.Add(rSStock); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(rSStock)); }
// GET: Stocks/Delete/5 public async Task <ActionResult> Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RSStock rSStock = await db.Stocks.FindAsync(id); if (rSStock == null) { return(HttpNotFound()); } return(View(rSStock)); }
private List <RSStock> ObtainStock(HtmlNode node) { List <RSStock> newStockList = new List <RSStock>(); List <HtmlNode> itemList = node.Descendants("tr").ToList(); for (int i = 1; i < itemList.Count; i++) { List <HtmlNode> columnList = itemList[i].Descendants("td").ToList(); if (columnList.Count > 0) { string key = columnList[1].InnerText.ToLower(); if (itemLookup.ContainsKey(key)) { RSStock newStock = new RSStock(); newStock.isNotCoin = false; newStock.itemId = itemLookup[key][0]; newStock.numberInStock = ObtainInt(columnList[2].InnerText); newStock.isInfinite = (columnList[2].InnerText == "∞"); newStock.priceSoldAt = ObtainInt(columnList[3].InnerText); if (columnList.Count == 6) { newStock.priceBoughtAt = ObtainInt(columnList[4].InnerText); } if (columnList.Count == 7) { newStock.isNotCoin = true; newStock.priceBoughtAt = ObtainInt(columnList[4].InnerText); } newStockList.Add(newStock); } } else { } } return(newStockList); }
public async Task <ActionResult> AddStock(int id, int stockId, double amount) { RSStock stock = await db.Stocks.FindAsync(stockId); RSProduct product = await db.Products.FindAsync(id); if (stock != null && product != null) { RSStockItem stockItem = new RSStockItem(); stockItem.Amount = amount; stockItem.Stock = stock; stockItem.Product = product; db.StockItems.Add(stockItem); await db.SaveChangesAsync(); return(Json(true)); } else { throw new HttpException(400, "Error inserting item"); } }