static void RunPriceManagementProcess() { NewPriceModel model = new NewPriceModel(); ICommandHandler handler = new CommandHandler(); PriceCommand priceCmd = new PriceCommand(model, ConsoleApp.Action.PriceAction.AddNewPrice); CommonUtils.ExecuteCommand(handler, priceCmd); }
private void ShowAndUpdatePrice(ProductModel selectedProduct) { Console.WriteLine($"Current Price: {selectedProduct.Price}/{selectedProduct.Measure}"); double newPriceInput = this.InputNewPrice(); this.PriceModel = new NewPriceModel { ProductId = selectedProduct.Id, Price = newPriceInput, ApplyDate = DateTime.Now, IsActive = true }; priceService.AddNewPrice(PriceModel); }
public void AddNewPrice(NewPriceModel priceModel) { try { var newPrice = new Entity.Price { ProductId = priceModel.ProductId, Value = priceModel.Price, ApplyDate = priceModel.ApplyDate, IsActive = priceModel.IsActive }; priceRepository.Insert(newPrice); } catch (Exception ex) { throw ex; } }
public PriceCommand(NewPriceModel model, PriceAction priceAction) { this.priceAction = priceAction; this.PriceModel = model; priceService = new PriceService(); }