public static long GetRemainingCredits(this DataCache dataCache, string account, long cost, long initialCredits, TimeSpan timeout, ICostCalculator costCalculator) { if (string.IsNullOrWhiteSpace(account)) { throw new ArgumentNullException("account"); } if (cost <= 0) { throw new ArgumentOutOfRangeException("cost", "Cost cannot be negative"); } if (initialCredits <= 0) { throw new ArgumentOutOfRangeException("initialCredits", "Initial credit cannot be negative"); } if (timeout.TotalMilliseconds <= 0) { throw new ArgumentOutOfRangeException("timeout", "Timeout must be a time interval"); } DataCacheItem cacheItem = dataCache.GetCacheItem(account); long remainingCredits; if (cacheItem == null) { remainingCredits = costCalculator.CalculateRemainingCredits(initialCredits, cost); if (remainingCredits <= 0) { return remainingCredits; } dataCache.Add(account, remainingCredits, timeout); return remainingCredits; } if (!(cacheItem.Value is long)) { throw new InvalidOperationException(string.Format("The cached value with key {0} is not a valid long", account)); } var cachedValue = (long) cacheItem.Value; if (cachedValue <= 0) { return -1; } remainingCredits = costCalculator.CalculateRemainingCredits(cachedValue, cost); var newTimeout = cacheItem.Timeout; dataCache.Put(account, remainingCredits, cacheItem.Version, newTimeout); return remainingCredits; }
public DeliveryCostCalculator(decimal costPerDelivery, decimal costPerProduct, decimal fixedCost, ShoppingCart cart, ICostCalculator calculatorStrategy) { CostPerDelivery = costPerDelivery; CostPerProduct = costPerProduct; CalculatorStrategy = calculatorStrategy; Cart = cart; FixedCost = fixedCost; }
public RentCostsBuilder() { _payment = new PaymentDetail(); _hotWaterCostsCalculator = new HotWaterCostsCalculator(); _coldWaterCostsCalculator = new ColdWaterCostsCalculator(); _heatingWaterCostsCalculator = new HeatingCostsCalculator(); _administrationCostsCalculator = new AdministrationCostsCalculator(); _garbageCostsCalculator = new GarbageCostsCalculator(); }
public WinkelwagenFacade(ICostCalculator calculator, IWinkelwagenRepository repositoryWinkelwagen, IKlantRepository repositoryKlant, IWinkelwagenMapper winkelwagenMapper) { _calculator = calculator; _repositoryWinkelwagen = repositoryWinkelwagen; _repositoryKlant = repositoryKlant; _winkelwagenMapper = winkelwagenMapper; }
public CostCalculatorTests() { _parcelRepositoryMock = new Mock <IParcelRepository>(); ConfigureRepositoryMock(CostCalculatorTestData.SmallParcel); ConfigureRepositoryMock(CostCalculatorTestData.MediumParcel); ConfigureRepositoryMock(CostCalculatorTestData.LargeParcel); ConfigureRepositoryMock(CostCalculatorTestData.XLParcel); _service = new Services.CostCalculator(_parcelRepositoryMock.Object); }
public Line(Bike bike, int quantity, ICostCalculator costCalculator) { _costCalculator = costCalculator; Brand = bike.Brand; Model = bike.Model; Price = bike.Price; Quantity = quantity; Cost = _costCalculator.CalculateCost(quantity, Price); }
public PlaceOrderCustomer(IEventBus eventBus, ICostCalculator costCalculator, IOrderNumberGenerator orderNumberGenerator, IOrdersRepository ordersRepository, OrdersDbContext dbContext, ICommandBus commandBus) { _eventBus = eventBus; _costCalculator = costCalculator; _orderNumberGenerator = orderNumberGenerator; _ordersRepository = ordersRepository; _dbContext = dbContext; _commandBus = commandBus; }
public BestellingFacade(IBestellingRepository repositoryBestelling, IWinkelwagenRepository repositoryWinkelwagen, IKlantRepository klantRepository, ICostCalculator costCalculator, IBestellingMapper bestellingMapper) { _repositoryBestelling = repositoryBestelling; _repositoryWinkelwagen = repositoryWinkelwagen; _klantRepository = klantRepository; _costCalculator = costCalculator; _bestellingMapper = bestellingMapper; }
private void OnConfirmClicked(object sender, EventArgs e) { printDialog = new PrintDialog(); if (printDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK) { XtraMessageBox.Show("Print has been Canceled By User"); return; } if (BLL.Settings.IsCenter) { GRV = new CenterCostCalculator(); GRV.LoadGRV(ReceiptID); GRV.CalculateFinalCost(); } else { GRV = new CostCalculator(); GRV.LoadGRV(ReceiptID); (GRV as CostCalculator).LoadGRVPreviousStock(); GRV.CalculateFinalCost(); } if (!SetSellingPrice(GRV)) { return; } HCMIS.Desktop.Reports.ReceiptConfirmationPrintout printout = new HCMIS.Desktop.Reports.ReceiptConfirmationPrintout(CurrentContext.LoggedInUserName); MyGeneration.dOOdads.TransactionMgr transaction = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr(); try { transaction.BeginTransaction(); // This is where we set the Price for the previous Stock foreach (CostElement costElement in GRV.CostElements) { costElement.PreviousCostDetials.Confirm(CurrentContext.UserId); } printout = PrintConfirmation(null); CostingService.ConfirmPriceChange(GRV.CostElements, CurrentContext.UserId, ChangeMode.Recieve, ReceiptID.ToString()); GRV.SetFinalCostlog(CurrentContext.UserId); transaction.CommitTransaction(); } catch (Exception ex) { transaction.RollbackTransaction(); XtraMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); throw; } printout.Print(printDialog.PrinterSettings.PrinterName); }
private void OnConfirmClicked(object sender, EventArgs e) { if (BLL.Settings.IsCenter) { GRV = new CenterCostCalculator(); GRV.LoadGRV(ReceiptID); GRV.CalculateFinalCost(); } else { GRV = new CostCalculator(); GRV.LoadGRV(ReceiptID); (GRV as CostCalculator).LoadGRVPreviousStock(); GRV.CalculateFinalCost(); } if (!SetSellingPrice(GRV)) { return; } TransactionMgr transaction = TransactionMgr.ThreadTransactionMgr(); try { transaction.BeginTransaction(); // This is where we set the Price for the previous Stock foreach (CostElement costElement in GRV.CostElements) { costElement.PreviousCostDetials.Confirm(CurrentContext.UserId); } PrintConfirmation(null); try { CostingService.ConfirmPriceChange(GRV.CostElements, CurrentContext.UserId, ChangeMode.Recieve, ReceiptID.ToString()); } catch (Exception exception) { XtraMessageBox.Show(exception.Message); throw exception; } transaction.CommitTransaction(); this.LogActivity("Print-SRM", ReceiptID); } catch (Exception ex) { transaction.RollbackTransaction(); XtraMessageBox.Show(ex.Message); } }
private bool SetSellingPrice(ICostCalculator CostCalculator) { foreach (CostElement costElement in CostCalculator.CostElements) { costElement.CheckMovingAverageCost(); using (SellingPriceValidation pricePerPackPage = new SellingPriceValidation(costElement.PreviousCostDetials)) { if (pricePerPackPage.ShowDialog(this) != System.Windows.Forms.DialogResult.OK) { return(false); } } } return(true); }
public void CanInjectArraysOfComponentsInConstructor2() { Order order1 = new Order(); order1.CountryCode = "NZ"; order1.Items.Add(new OrderItem("water", 10, 1.0m, false)); order1.Items.Add(new OrderItem("glass", 5, 20.0m, true)); Order order2 = new Order(); order2.CountryCode = "US"; order2.Items.Add(new OrderItem("sand", 50, 0.2m, false)); ICostCalculator costCalculator = _container.Resolve <ICostCalculator>("cost_calculator_default"); Assert.AreEqual(110m, costCalculator.CalculateTotal(order1)); Assert.AreEqual(10m, costCalculator.CalculateTotal(order2)); }
public PathfinderEngine(int width, int height, ICostCalculator costCalculator, IHeuristicCalculator heuristicCalculator, MovementMode explorationMode = MovementMode.FourDirection) { Debug.Assert(width > 0, "width <= 0"); Debug.Assert(height > 0, "height <= 0"); _width = width; _height = height; this.MovementMode = explorationMode; _solution = new PathfinderNode[width, height]; CostCalculator = costCalculator; HeuristicCalculator = heuristicCalculator; }
private static void CalculateRentTest() { Write("Podaj imię: "); string firstName = ReadLine(); Write("Podaj nazwisko: "); string lastName = ReadLine(); var rentee = new Man(); rentee.FirstName = firstName; rentee.LastName = lastName; Product item = new CrossCountrySki { Id = 1, PricePerHour = 50, Name = "Fisher", Size = 150, }; var rent = new Rent(rentee, item) { Id = 1, }; // zwrot Thread.Sleep(TimeSpan.FromSeconds(1)); rent.Return(); ICalculatorFactory calculatorFactory = new CalculatorFactory(); ICostCalculator calculator = calculatorFactory.Create(rent); rent.Cost = calculator.Calculate(rent); }
private bool SetSellingPrice(ICostCalculator CostCalculator) { foreach (CostElement costElement in CostCalculator.CostElements) { costElement.CheckMovingAverageCost(); if (costElement.PreviousCostDetials.PreviousStock.Rows.Count > 0) { using (SellingPriceValidation pricePerPackPage = new SellingPriceValidation(costElement.PreviousCostDetials)) { if (pricePerPackPage.ShowDialog(this) != System.Windows.Forms.DialogResult.OK) return false; } } } return true; }
private void OnConfirmClicked(object sender, EventArgs e) { if (BLL.Settings.IsCenter) { GRV = new CenterCostCalculator(); GRV.LoadGRV(ReceiptID); GRV.CalculateFinalCost(); } else { GRV = new CostCalculator(); GRV.LoadGRV(ReceiptID); (GRV as CostCalculator).LoadGRVPreviousStock(); GRV.CalculateFinalCost(); } if(!SetSellingPrice(GRV)) { return; } TransactionMgr transaction = TransactionMgr.ThreadTransactionMgr(); try { transaction.BeginTransaction(); // This is where we set the Price for the previous Stock foreach (CostElement costElement in GRV.CostElements) { costElement.PreviousCostDetials.Confirm(CurrentContext.UserId); } PrintConfirmation(null); try { CostingService.ConfirmPriceChange(GRV.CostElements, CurrentContext.UserId, ChangeMode.Recieve, ReceiptID.ToString()); } catch (Exception exception) { XtraMessageBox.Show(exception.Message); throw exception; } transaction.CommitTransaction(); this.LogActivity("Print-SRM", ReceiptID); } catch (Exception ex) { transaction.RollbackTransaction(); XtraMessageBox.Show(ex.Message); } }
private void OnConfirmClicked(object sender, EventArgs e) { printDialog = new PrintDialog(); if (printDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK) { XtraMessageBox.Show("Print has been Canceled By User"); return; } if (BLL.Settings.IsCenter) { GRV = new CenterCostCalculator(); GRV.LoadGRV(ReceiptID); GRV.CalculateFinalCost(); } else { GRV = new CostCalculator(); GRV.LoadGRV(ReceiptID); (GRV as CostCalculator).LoadGRVPreviousStock(); GRV.CalculateFinalCost(); } if(!SetSellingPrice(GRV)) { return; } HCMIS.Desktop.Reports.ReceiptConfirmationPrintout printout = new HCMIS.Desktop.Reports.ReceiptConfirmationPrintout(CurrentContext.LoggedInUserName); MyGeneration.dOOdads.TransactionMgr transaction = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr(); try { transaction.BeginTransaction(); // This is where we set the Price for the previous Stock foreach (CostElement costElement in GRV.CostElements) { costElement.PreviousCostDetials.Confirm(CurrentContext.UserId); } printout = PrintConfirmation(null); CostingService.ConfirmPriceChange(GRV.CostElements, CurrentContext.UserId, ChangeMode.Recieve, ReceiptID.ToString()); GRV.SetFinalCostlog(CurrentContext.UserId); transaction.CommitTransaction(); } catch (Exception ex) { transaction.RollbackTransaction(); XtraMessageBox.Show(ex.Message,"Error",MessageBoxButtons.OK,MessageBoxIcon.Error); throw ; } printout.Print(printDialog.PrinterSettings.PrinterName); }
ServiceTaxApplicableCostCalculator( ICostCalculator with, ICostCalculator without) { this.with = with; this.without = without; }
public NightInOtherLines(ICostCalculator inner) { _inner = inner; }
public App(IShoppingCart shoppingCart, ICostCalculator costCalculator) { _shoppingCart = shoppingCart; _costCalculator = costCalculator; }
public PeakHourInOtherLines(ICostCalculator inner) { _inner = inner; }
public AzureCacheThrottlingService(DataCache dataCache, ICostCalculator costCalculator) { _dataCache = dataCache; _costCalculator = costCalculator; }
public BestInsertion(ICostCalculator costCalculator) { _costCalculator = costCalculator; }
public InterchangingAtNonPeak(ICostCalculator inner) { _inner = inner; }
public SuperSendingMicroApp(ICostCalculator cost, IMessageSender sender, IAppLogger logger) { _cost = cost ?? throw new ArgumentNullException(nameof(cost), $"{nameof(cost)} is null."); _sender = sender ?? throw new ArgumentNullException(nameof(sender), $"{nameof(sender)} is null."); _logger = logger ?? throw new ArgumentNullException(nameof(logger), $"{nameof(logger)} is null."); }
protected PathFinder(NodeHandler nodeHandler, ICostCalculator costCalculator) { NodeHandler = nodeHandler; CostCalculator = costCalculator; }
public RentalsController(BikeRentalDbContext context, ICostCalculator calculator) { _context = context; _calculator = calculator; }
public InterchangingAtNight(ICostCalculator inner) { _inner = inner; }
public InterchangingAtPeakHour(ICostCalculator inner) { _inner = inner; }
public DataAccess(ICostCalculator c) { context = new Context(); calculator = c; }
public NonPeakInDtTe(ICostCalculator inner) { _inner = inner; }
public CostCalculatorTest() { CostCalculator = new CostCalculator(); }
public DisabledJourneyTime(ICostCalculator inner) { _inner = inner; }
public PeakHourInNeNs(ICostCalculator inner) { _inner = inner; }
public ConstructionWithBestInsertion(IRouteRepository routeRepository, IBestInsertion bestInsertion, INodeAndArcRepository nodeAndArcRepository, ICostCalculator costCalculator) { _routeRepository = routeRepository; _bestInsertion = bestInsertion; _nodeAndArcRepository = nodeAndArcRepository; }
public OrOpt(IRouteRepository routeRepository, ICostCalculator costCalculator) { _routeRepository = routeRepository; _costCalculator = costCalculator; }