public string Save(DAL.Entity.StockIn stockIn) { string message = ""; bool itemExist = stockInGateway.DoesItemExist(stockIn.ItemId); if (itemExist) { int rowAffected = stockInGateway.Update(stockIn); if (rowAffected > 0) { message = "Saved Successfully"; } else { message = "Could not be saved"; } } else { int rowAffected = stockInGateway.Save(stockIn); if (rowAffected > 0) { message = "Saved Successfully"; } else { message = "Could not be saved"; } } return(message); }
public string SaveManager(StockIn stockIn) { if (stockIn.StockQuantity == 0) { return("Stock Quantity should be filled"); } else if (stockInGateway.IsStockExist(stockIn)) { int stockQuantityAvailable = stockInGateway.StockQuantityAvailable(stockIn); stockIn.StockQuantity = stockIn.StockQuantity + stockQuantityAvailable; int row = stockInGateway.Update(stockIn); if (row > 0) { return("Save Successful !"); } else { return("Saving Failed !"); } } else { int row = stockInGateway.SaveGateway(stockIn); if (row > 0) { return("Save Successful !"); } else { return("Saving Failed !"); } } }
public string Update(StockIn stockIn) { int rowAffected = stockInGateway.Update(stockIn); if (rowAffected > 0) { return("Stock in Updated successfully"); } return("Stock in Updated failed"); }
public string Update(int itemId, int quantity) { int availablequantity = stockInGateway.GetStockInById(itemId); availablequantity -= quantity; StockIn stockIn = new StockIn(); stockIn.ItemId = itemId; stockIn.AvailableQuantity = availablequantity; int rowAffect = stockInGateway.Update(stockIn); if (rowAffect > 0) { return("Update Successful"); } else { return("Update Failed"); } }