// GET: Stocks public ActionResult Index() { var stocks = StockRepository.GetStocks(); var stockIds = stocks.Select(i => i.Id).ToList(); var stockControls = StockControlRepository.GetStockControls(); var categoryStocks = stockControls.Where(t => stockIds.Contains(t.StockId)); foreach (var stock in stocks) { var stockControlId = StockControlRepository.GetStockControlById(stock.Id); if (stock.StockControls == null) { stock.StockControls = new List <StockControl>(); } if (stockControlId.StockId == stock.Id) { stock.StockControls.AddRange(categoryStocks); } } return(View(stocks)); }
public void InsertStockControlTest() { StockControlRepository.Insert(stockControl); var stockControlFromList = StockControlRepository.GetStockControlById(stockControl.Id); Assert.AreEqual(stockControl, stockControlFromList); }
public void GetStockControlByIdTest() { StockControlRepository.Insert(stockControl); var stockControlFromList = StockControlRepository.GetStockControlById(stockControl.Id); Assert.IsNotNull(stockControlFromList); }
public void RemoveStockControlTest() { StockControlRepository.Insert(stockControl); var stockControlFromList = StockControlRepository.GetStockControlById(stockControl.Id); StockControlRepository.Remove(stockControlFromList); var checkRemovedStockControl = StockControlRepository.GetStockControlById(stockControlFromList.Id); Assert.IsNull(checkRemovedStockControl); }
public void UpdateStockControlTest() { StockControlRepository.Insert(stockControl); var stockControlFromList = StockControlRepository.GetStockControlById(stockControl.Id); stockControlFromList.ProductAmount = 6000; stockControlFromList.Product.Description = "Frut Test"; stockControlFromList.Product.PurchasePrice = .99; StockControlRepository.Update(stockControlFromList); Assert.Contains(stockControlFromList, StockControlRepository.GetStockControls()); }
public void GetInitialStockControlTest() { stockControlList = StockControlRepository.GetStockControls(); if (stockControlList.Count() <= 0) { Assert.IsEmpty(stockControlList); } else { Assert.IsNotEmpty(stockControlList); } }
public ActionResult DeleteConfirmed(int id) { var stockControl = StockControlRepository.GetStockControlById(id); try { StockControlRepository.Remove(stockControl); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public ActionResult Edit(int id, StockControl stockControl) { try { StockControlRepository.Update(stockControl); return(RedirectToAction(nameof(Index))); } catch { var stocks = StockRepository.GetStocks(); ViewData["StockId"] = new SelectList(stocks, "Id", "StockName"); return(View()); } }
// GET: StockControls/Details/5 public ActionResult Details(int id) { var stockControl = StockControlRepository.GetStockControlById(id); return(View(stockControl)); }
// GET: StockControls public ActionResult Index() { var stockControls = StockControlRepository.GetStockControls(); return(View(stockControls)); }