public void AskDeleteStockMessage(StockRowViewModel selectedStock) { string msg = string.Format("You are sure to delete this stock?"); var result = MessageBox.Show(this, msg, "Delete stock", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (result == DialogResult.Yes) { _presenter.DeleteStock(selectedStock); } }
public static StockRowViewModel ToStockRowViewModel(this Item it) { var vm = new StockRowViewModel(); vm.Identifier = it.Identifier; vm.Name = it.Name; vm.Description = it.Description; vm.Manufacturer = it.Manufacturer; vm.StockLevel = it.StockLevel; vm.ReOrderLevel = it.ReOrderLevel; vm.MajorSupplier = it.MajorSupplier; vm.PurchasePrice = it.PurchasePrice; vm.SellingPrice = it.SellingPrice; return(vm); }
internal void DeleteStock(StockRowViewModel selectedStock) { try { using (var ctx = new InventoryModel()) { var stockToDelete = ctx.Items .Single(x => x.Identifier == selectedStock.Identifier); ctx.Items.Remove(stockToDelete); ctx.SaveChanges(); } } catch (Exception ex) { View.ShowError(ex); } }
public void ShowUpdateStockForm(StockRowViewModel selectedStock) { var form = new UpdateStockForm(selectedStock.Identifier); form.Show(this); }