public List <StockLevel> GetItemStockLevel(string itemCode) { { StringBuilder oSQL = new StringBuilder(); oSQL.Append("select T0.WhsCode, T1.WhsName, OnHand, IsCommited, OnOrder, OnHand + OnOrder - IsCommited IsAvailable "); oSQL.Append("From OITW T0 inner join OWHS T1 on T0.WhsCode = T1.WhsCode "); oSQL.Append("where ItemCode = @itemCode and (OnHand > 0 or OnOrder > 0)"); DbCommand dbCommand = this.dataBase.GetSqlStringCommand(oSQL.ToString()); this.dataBase.AddInParameter(dbCommand, "itemCode", DbType.String, itemCode); List <StockLevel> itemStockLevel = new List <StockLevel>(); using (this.reader = this.dataBase.ExecuteReader(dbCommand)) { while (this.reader.Read()) { StockLevel stockWhs = new StockLevel(); stockWhs.WhsCode = this.reader.IsDBNull(0) ? "" : this.reader.GetValue(0).ToString(); stockWhs.WhsName = this.reader.IsDBNull(1) ? "" : this.reader.GetValue(1).ToString(); stockWhs.OnHand = this.reader.IsDBNull(2) ? 0 : double.Parse(this.reader.GetValue(2).ToString()); stockWhs.IsCommited = this.reader.IsDBNull(3) ? 0 : double.Parse(this.reader.GetValue(3).ToString()); stockWhs.OnOrder = this.reader.IsDBNull(4) ? 0 : double.Parse(this.reader.GetValue(4).ToString()); stockWhs.IsAvailable = this.reader.IsDBNull(5) ? 0 : double.Parse(this.reader.GetValue(5).ToString()); itemStockLevel.Add(stockWhs); } } return(itemStockLevel); } }
public ActionResult <StockLevel> Add(int productId, [FromBody] AddStocksCommand command) { var quantityInStock = _stockService.AddStock(productId, command.Amount); var stockLevel = new StockLevel(quantityInStock); return(Ok(stockLevel)); }
public ActionResult DeleteConfirmed(int id) { StockLevel stockLevel = db.StockLevels.Find(id); db.StockLevels.Remove(stockLevel); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult <StockLevel> Add( int productId, [FromBody] AddStocksCommand command, [FromServices] AddStocks useCase ) { var product = useCase.Handle(productId, command.Amount); var stockLevel = new StockLevel(product.QuantityInStock); return(Ok(stockLevel)); }
public ActionResult Edit([Bind(Include = "ProductStockLevelID,StockID,ProductStockLevel")] StockLevel stockLevel) { if (ModelState.IsValid) { db.Entry(stockLevel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.StockID = new SelectList(db.Stocks, "StockID", "ProductName", stockLevel.StockID); return(View(stockLevel)); }
public async Task <ActionResult <StockLevel> > AddAsync( int productId, [FromBody] AddStocks.Command command ) { command.ProductId = productId; var product = await _mediator.Send(command); var stockLevel = new StockLevel(product.QuantityInStock); return(Ok(stockLevel)); }
private static string ToStockLevelText(StockLevel stockLevel) { switch (stockLevel) { case StockLevel.Low: return("Only a few left"); case StockLevel.SoldOutMoreNoRestock: return("Sold out"); case StockLevel.SoldOutMoreSoon: return("Sold out, more comming soon!"); default: return(string.Empty); } }
public async Task <ActionResult <StockLevel> > AddAsync( int productId, [FromBody] AddStocks.Command command, CancellationToken cancellationToken ) { command.ProductId = productId; var quantityInStock = await _mediator.Send(command, cancellationToken); var stockLevel = new StockLevel(quantityInStock); return(Ok(stockLevel)); }
// GET: StockLevels/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StockLevel stockLevel = db.StockLevels.Find(id); if (stockLevel == null) { return(HttpNotFound()); } return(View(stockLevel)); }
// GET: StockLevels/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StockLevel stockLevel = db.StockLevels.Find(id); if (stockLevel == null) { return(HttpNotFound()); } ViewBag.StockID = new SelectList(db.Stocks, "StockID", "ProductName", stockLevel.StockID); return(View(stockLevel)); }
public IEnumerable FilterByStock(StockLevel level) { switch (level) { case StockLevel.Low: return(_db.Products.Where(u => u.UnitsInStock < 50).Select(p => p.ProductName).ToList()); case StockLevel.Normal: return(_db.Products.Where(u => u.UnitsInStock >= 50 && u.UnitsInStock <= 100).Select(p => p.ProductName).ToList()); case StockLevel.Overstocked: return(_db.Products.Where(u => u.UnitsInStock > 100).Select(p => p.ProductName).ToList()); default: return(null); } }
public ActionResult <StockLevel> Remove(int productId, [FromBody] RemoveStocksCommand command) { try { var quantityInStock = _stockService.RemoveStock(productId, command.Amount); var stockLevel = new StockLevel(quantityInStock); return(Ok(stockLevel)); } catch (NotEnoughStockException ex) { return(Conflict(new { ex.Message, ex.AmountToRemove, ex.QuantityInStock })); } }
public async Task <ActionResult <StockLevel> > RemoveAsync( int productId, [FromBody] RemoveStocks.Command command ) { try { command.ProductId = productId; var product = await _mediator.Send(command); var stockLevel = new StockLevel(product.QuantityInStock); return(Ok(stockLevel)); } catch (NotEnoughStockException ex) { return(Conflict(new { ex.Message, ex.AmountToRemove, ex.QuantityInStock })); } }
public IActionResult GetByStockLevel(StockLevel stockLevel, int pageSize = 25, int pageCount = 0) { return(Ok(_searchContext.GetByStockLevels(new[] { stockLevel }, pageCount, pageSize))); }
public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append(ItemKey.ToString()).Append(" ").Append(ItemName.ToString()).Append(" ").Append(BarCodeNum.ToString()).Append(" ").Append(RetailPrice.ToString()).Append(" ").Append(ThresholdNum.ToString()).Append(" ").Append(StockLevel.ToString()).Append(" ").Append(SuppliersKey.ToString()); return(sb.ToString()); }