예제 #1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            PriceService priceService = new PriceService();

            int currentMinute = 10;

            CreateCommand <BuyViewModel> createCalculatePriceCommand;
            CreateCommand <BuyViewModel> createBuyCommand;

            if (currentMinute % 2 == 1)
            {
                createCalculatePriceCommand = (vm) => new CalculatePriceCommand(vm, priceService);
                createBuyCommand            = (vm) => new BuyCommand(vm, priceService);
            }
            else
            {
                CreateCommand <BuyViewModel> createStoreClosedCommand = (vm) => new StoreClosedCommand(vm);

                createCalculatePriceCommand = createStoreClosedCommand;
                createBuyCommand            = createStoreClosedCommand;
            }

            BuyViewModel initialViewModel = new BuyViewModel(createCalculatePriceCommand, createBuyCommand);

            MainWindow = new MainWindow()
            {
                DataContext = initialViewModel
            };

            MainWindow.Show();

            base.OnStartup(e);
        }
예제 #2
0
        public BuyCommand(BuyViewModel viewModel, PriceService priceService)
        {
            _viewModel    = viewModel;
            _priceService = priceService;

            _viewModel.PropertyChanged += ViewModel_PropertyChanged;
        }
        public ActionResult EditPricing(EditPriceModel WebPageData)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    IPriceService PricingService = new PriceService();
                    bool          updateStatus   = PricingService.UpdatePrice(WebPageData);

                    if (updateStatus == true)
                    {
                        return(RedirectToAction("ManagePricings", "Administration"));
                    }
                    else
                    {
                        ModelState.AddModelError("", "Failed to update the record");
                    }
                }
            }
            catch (Exception Ex)
            {
                ModelState.AddModelError("", Common.StandardExceptionErrorMessage(Ex));
            }
            // If we got this far, something failed, redisplay form
            return(View(WebPageData));
        }
        public ActionResult DeletePricing(int ID)
        {
            IPriceService  PricingService = new PriceService();
            EditPriceModel WebPrice       = PricingService.GetPrice(ID);

            return(View(WebPrice));
        }
        public ActionResult AddPricing(AddPriceModel WebPageData)
        {
            if (ModelState.IsValid)
            {
                // Attempt to add the chain
                IPriceService PricingService = new PriceService();
                try
                {
                    bool createStatus = PricingService.AddPrice(WebPageData);

                    if (createStatus == true)
                    {
                        return(RedirectToAction("ManagePricings", "Administration"));
                    }
                    else
                    {
                        ModelState.AddModelError("", "Failed to create the record");
                    }
                }
                catch (Exception Ex)
                {
                    ModelState.AddModelError("", Common.StandardExceptionErrorMessage(Ex));
                }
            }
            // If we got this far, something failed, redisplay form
            return(View(WebPageData));
        }
예제 #6
0
 protected override async Task OnInitializedAsync()
 {
     Prices        = PriceService.GetPrices().Where(c => c.Symbol == StockPick).OrderByDescending(c => c.Date).Take(Days);
     CurrentPrice  = Prices.OrderBy(p => p.Date).Select(c => c.Close).Last();
     PreviousPrice = Prices.OrderBy(p => p.Date).Select(p => p.Close).Skip(1).FirstOrDefault();
     AmounttoBuy   = Amount / CurrentPrice;
 }
예제 #7
0
        public void SimpleConversion()
        {
            var options = new DbContextOptions()
                          .UseInMemoryStore();

            using (var db = new CycleSalesContext(options))
            {
                // Arange
                db.Bikes.Add(new Bike {
                    Bike_Id = 1, Retail = 100M
                });
                db.Bikes.Add(new Bike {
                    Bike_Id = 2, Retail = 99.95M
                });
                db.SaveChanges();

                // Act
                var convertor = new PriceService(db);
                var results   = convertor.CalculateForeignPrices(exchangeRate: 2).ToArray();

                // Assert
                Assert.AreEqual(2, results.Length);

                Assert.AreEqual(100M, results[0].USPrice);
                Assert.AreEqual(199.95M, results[0].ForeignPrice);

                Assert.AreEqual(99.95M, results[1].USPrice);
                Assert.AreEqual(199.90M, results[1].ForeignPrice);
            }
        }
        public static Product CreateProduct(StripeProductInfoModel model)
        {
            var stripeKey = StripeApiKey();

            var options = new ProductCreateOptions
            {
                Description = model.Description,
                Name        = model.Name,
                Active      = model.Active,
            };

            var service = new ProductService();
            var product = service.Create(options);

            var priceOption = new PriceCreateOptions
            {
                Product    = product.Id,
                UnitAmount = long.Parse(model.Price),
                Currency   = "usd",
            };
            var priceService = new PriceService();
            var price        = priceService.Create(priceOption);

            return(product);
        }
예제 #9
0
        private string GetMaxPriceType(Entities.Context.Order order,
                                       List <OrderDetail> newOrderDetails)
        {
            var orderDetailIDs = newOrderDetails.Select(od => od.OrderDetailID);
            var trackDetails   = order.OrderDetails.Where(od =>
                                                          orderDetailIDs.Contains(od.OrderDetailID));

            var prices = new List <PriceView>();

            foreach (var orderDetail in trackDetails)
            {
                orderDetail.Group_ID = newOrderDetails.FirstOrDefault(
                    od => od.OrderDetailID == orderDetail.OrderDetailID).Group_ID;
                if (orderDetail.Group_ID == null)
                {
                    continue;
                }

                var group = GroupService.GetPlannedAndNotBegin()
                            .ByPrimeryKey(orderDetail.Group_ID);
                var priceTypeTC = OrderService.GetPriceTypeForGroup(
                    group, false, order.CustomerType);
                var price = PriceService.GetAllPricesForCourse(orderDetail.Course_TC,
                                                               orderDetail.Track_TC).FirstOrDefault(p => p.PriceType_TC == priceTypeTC);
                if (price != null)
                {
                    prices.Add(price);
                }
            }
            return(prices.AsQueryable().SelectMax(p => p.Price).PriceType_TC);
        }
예제 #10
0
        public void GetItemPrice()
        {
            var fileReader = new Mock <IProductCatalogFileReader>();

            fileReader.Setup(x => x.GetTextReader()).Returns(_catalogTestData.GetValidTestData());

            var testRepository = new ProductCatalogRepository(fileReader.Object);

            var priceService = new PriceService(testRepository);

            var saleItem = new BasketItem()
            {
                Name = "Apple"
            };

            var normalItem = new BasketItem()
            {
                Name = "Banana"
            };

            var saleItemResult   = priceService.GetItemPrice(saleItem);
            var normalItemResult = priceService.GetItemPrice(normalItem);

            Assert.IsTrue(saleItemResult == 0.50M);
            Assert.IsTrue(normalItemResult == 0.75M);
        }
예제 #11
0
        /// <summary>
        /// Calculates the proposed sale unit sale price dependant upon form - size
        /// </summary>
        /// <param name="batch"></param>
        /// <returns>Proposed unit Sale Price</returns>
        private static decimal CalCapPrice(ImportModel.Pannebakker batch)
        {
            // pb buy price
            var y = batch.Price;
            // base sales price
            var x = (batch.Price / 0.55m);

            PriceItemDTO price = PriceService.GetUnitPrice(batch.FormSize, batch.FormSizeCode);

            if (price != null)
            {
                var max = Convert.ToDecimal(price.MaxUnitValue * 100);
                var min = Convert.ToDecimal(price.MinUnitValue * 100);
                if (x < min)
                {
                    return(min + y);
                }
                if (x > max)
                {
                    return(max + y);
                }
            }
            else
            {
                return(0);
            }
            return(y);
        }
예제 #12
0
        public async Task <Price> GetPrice()
        {
            var priceService = new PriceService(_client);
            var price        = await priceService.GetAsync("price_1I9BDlLEKfRfXn5LnzigkJpT");

            return(price);
        }
예제 #13
0
        public ActionResult WithDiscount(string courseTC)
        {
            var groups = GroupService.GetGroupsForCourse(courseTC)
                         .Where(x => x.Discount.HasValue && !x.IsOpenLearning).ToList();

            var prices = PriceService.GetAllPricesForCourse(courseTC, null);

            var course      = CourseService.GetByPK(courseTC);
            var actionBlock = new PagePart(string.Empty);

            if (groups.Any(x => x.Discount == CommonConst.GoldFallDiscount))
            {
                actionBlock = new PagePart(
                    Htmls.HtmlBlock(HtmlBlocks.GoldFallLarge));
            }

            return(BaseView(
                       new PagePart(H.h3[Html.CourseLink(course)].ToString()),
                       actionBlock,
                       new PagePart(
                           Views.Shared.Education.NearestGroupList,
                           new GroupsWithDiscountVM(groups, true)
            {
                Course = course,
                Prices = prices
            })));
        }
예제 #14
0
 private void UpdatePrices(Order order)
 {
     foreach (var detail in order.GetCourseOrderDetails())
     {
         var price = PriceService.GetAllPricesForCourse(detail.Course_TC, detail.Track_TC)
                     .FirstOrDefault(x => x.PriceType_TC == detail.PriceType_TC);
         if (price != null)
         {
             detail.Price = price.Price;
         }
         else
         {
             order.OrderDetails.Remove(detail);
         }
     }
     foreach (var orderExam in order.OrderExams.ToList())
     {
         var price = ExamService.GetValues(orderExam.Exam_ID, x => x.ExamPrice);
         if (price.GetValueOrDefault() > 0)
         {
             orderExam.Price = price.Value;
         }
         else
         {
             order.OrderExams.Remove(orderExam);
         }
     }
 }
예제 #15
0
        public IList <CheckResult <AddressDTO> > CallCheckAddress(IUnitOfWork db, string orderId)
        {
            var order                = db.Orders.GetFiltered(o => o.AmazonIdentifier == orderId).First();
            var orderInfo            = db.ItemOrderMappings.GetSelectedOrdersWithItems(null, new[] { order.Id }, includeSourceItems: false).First();
            var addressTo            = db.Orders.GetAddressInfo(orderInfo.OrderId);
            var dbFactory            = new DbFactory();
            var time                 = new TimeService(dbFactory);
            var serviceFactory       = new ServiceFactory();
            var addressCheckServices = serviceFactory.GetAddressCheckServices(_log,
                                                                              _time,
                                                                              dbFactory,
                                                                              _company.AddressProviderInfoList);
            var priceService = new PriceService(dbFactory);

            var        companyAddress   = new CompanyAddressService(_company);
            var        addressService   = new AddressService(addressCheckServices, companyAddress.GetReturnAddress(MarketIdentifier.Empty()), companyAddress.GetPickupAddress(MarketIdentifier.Empty()));
            AddressDTO outAddress       = null;
            var        validatorService = new OrderValidatorService(_log, _dbFactory, null, null, null, null, priceService, _htmlScraper, addressService, null, null, time, _company);

            var result = validatorService.CheckAddress(CallSource.Service,
                                                       db,
                                                       addressTo,
                                                       order.Id,
                                                       out outAddress);


            Console.WriteLine("Validation result: " + result);

            return(result);
        }
예제 #16
0
        // GET: FSPrice/Details/5
        public ActionResult Calculate()
        {
            // empty batches object to fill soon
            //var batches = new List<DTO.BatchDTO>();
            //var VM = new List<DTO.BatchEditVM>();
            // dear service can i have the batches please
            var Allbatches = db.GetPBBatches();
            var unChanged  = Allbatches.Where(b => b.Comment == null);
            List <ImportModel.Batch> updateList = new List <ImportModel.Batch>();

            foreach (var b in unChanged)
            {
                // lets build a model we can edit
                /// get price datavar
                ///
                if (b.Id == 6854)
                {
                    var found = true;
                }
                int?         WholeSalePrice = b.WholesalePrice;
                PriceItemDTO batchWithPrice = PriceService.GetUnitPrice(b.FormSize, b.FormSizeCode);
                if (batchWithPrice == null)
                {
                    //DTO.BatchEditVM vm = new DTO.BatchEditVM();
                    //vm.BatchId = b.Id;
                    //vm.Sku = b.Sku;
                    //vm.Name = b.Name;
                    //vm.FormSize = b.FormSize;
                    //vm.FormSizeCode = b.FormSizeCode;
                    //vm.formType = "Dont Know";
                    //vm.PriceRule = "No Price Band";
                    //vm.maxPrice = 0;
                    //vm.minPrice = Convert.ToInt32(b.WholesalePrice)/100;
                    //VM.Add(vm);
                    //    var max = batchWithPrice.MaxUnitValue * 100;
                    //    var min = batchWithPrice.MinUnitValue * 100;
                    //    if (b.Price < min)
                    //    {
                    //        WholeSalePrice = Convert.ToInt32(min) + b.Price;

                    //    }
                    //    if (b.Price > max)
                    //    {
                    //        WholeSalePrice = Convert.ToInt32(max) + b.Price;
                    //    }
                    //ImportService.DTO.BatchPriceDTO newPrice = new ImportService.DTO.BatchPriceDTO();
                    //newPrice.BatchId = b.Id;
                    //newPrice.Price = Convert.ToInt32(WholeSalePrice);
                }
                else
                {
                    // nothing yet
                    var newPrice = PriceService.CalCapPrice(b);
                    b.WholesalePrice = Convert.ToInt32(newPrice);
                    updateList.Add(b);
                }
            }
            db.BatchUpdate(updateList);
            return(RedirectToAction("Index"));
        }
예제 #17
0
        public void GetPriceForArticleTest()
        {
            var request  = new FortnoxApiRequest(this.connectionSettings.AccessToken, this.connectionSettings.ClientSecret);
            var response = PriceService.GetPriceForArticleAsync(request, "A", "10", "0").GetAwaiter().GetResult();

            Assert.IsTrue(response.PriceValue == 320);
        }
        public IActionResult DoublePrices()
        {
            var svc = new PriceService(db);

            svc.UpdatePrices(2);
            return(RedirectToAction("Index"));
        }
예제 #19
0
 public ClientController(
     IMarketDataMemCacheService memCacheService,
     PriceService priceService)
 {
     _marketDataService = memCacheService;
     _priceService      = priceService;
 }
예제 #20
0
        public void SimpleConversion()
        {
            // TODO Test currently hits a real database, replace with something in-memory

            using (var db = new CycleSalesContext())
            {
                // Arange
                db.Bikes.Add(new Bike {
                    Bike_Id = 1, Retail = 100M
                });
                db.Bikes.Add(new Bike {
                    Bike_Id = 2, Retail = 99.95M
                });
                db.SaveChanges();

                // Act
                var convertor = new PriceService(db);
                var results   = convertor.CalculateForeignPrices(exchangeRate: 2).ToArray();

                // Assert
                Assert.AreEqual(2, results.Length);

                Assert.AreEqual(100M, results[0].USPrice);
                Assert.AreEqual(199.95M, results[0].ForeignPrice);

                Assert.AreEqual(99.95M, results[1].USPrice);
                Assert.AreEqual(199.90M, results[1].ForeignPrice);
            }
        }
예제 #21
0
        static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.WriteLine("Expected 1 argument, found {0}\n\nUsage: {1} shoppingListFile\nWhere the shoppingListFile is a flat text file containing one product per line", args.Length, AppDomain.CurrentDomain.FriendlyName);
                Console.WriteLine();
                Console.WriteLine("Press any key to continue...");
                Console.ReadKey();
                return;
            }

            var cartService = new CartService();
            var cart        = cartService.GetCartFromFile(args[0]);

            Directory.SetCurrentDirectory(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "../../../../Input Files/");
            var priceService = new PriceService();
            var priceCatalog = priceService.GetPriceCatalogFromFile("priceCatalog.json");

            var saleService = new SaleService();
            var sales       = saleService.GetSalesFromFile("saleCatalog.json");

            Receipt receipt;
            decimal total = priceService.GetPrice(cart, priceCatalog, sales, out receipt);

            Console.WriteLine(receipt);
            Console.ReadKey();
        }
예제 #22
0
        public IActionResult GetAllProducts()
        {
            StripeConfiguration.ApiKey = "****************";
            List <object> resultList = new List <object>();

            try
            {
                var options = new PriceListOptions {
                    Currency = "sgd"
                };
                var service = new PriceService();
                StripeList <Price> prices = service.List(options);

                foreach (Price p in prices)
                {
                    float  amount = (float)p.UnitAmount / 100;
                    string id     = p.Id;
                    resultList.Add(new
                    {
                        id     = id,
                        amount = amount,
                    });
                }
            }
            catch {
                return(BadRequest());
            }
            return(Ok(new JsonResult(resultList)));
        }
예제 #23
0
파일: CartService.cs 프로젝트: dKluev/Site
        public void AddTrack(string trackTC, string priceTypeTC)
        {
            var order = OrderService.GetOrCreateCurrentOrder();

            if (order.OrderDetails.Any(od => od.Track_TC == trackTC))
            {
                return;
            }
            if (priceTypeTC == null)
            {
                var price = PriceService.GetAllPricesForCourse(trackTC, null).AsQueryable()
                            .GetDefault();
                priceTypeTC = price.GetOrDefault(x => x.PriceType_TC);
            }
            var courses =
                CourseService.GetAllForTrack(trackTC);

            foreach (var course in courses)
            {
                var orderDetail = CreateDetail(course.Course_TC, trackTC, priceTypeTC);
                if (orderDetail == null)
                {
                    return;
                }
                order.OrderDetails.Add(orderDetail);
            }
            CleanTestCertsDopUslExamsAndSubmit(order);
        }
        public void Simple_price_increase()
        {
            var options = new DbContextOptions <CycleSalesContext>()
                          .UseInMemoryStore();

            // Arrange
            using (var db = new CycleSalesContext(options))
            {
                db.Database.EnsureDeleted();
                db.Database.EnsureCreated();

                db.Bikes.Add(new Bike {
                    Retail = 200
                });
                db.Bikes.Add(new Bike {
                    Retail = 100
                });
                db.SaveChanges();
            }

            // Act
            using (var db = new CycleSalesContext(options))
            {
                var svc = new PriceService(db);
                svc.UpdatePrices(2);
            }

            // Assert
            using (var db = new CycleSalesContext(options))
            {
                Assert.True(db.Bikes.Any(b => b.Retail == 400));
                Assert.True(db.Bikes.Any(b => b.Retail == 200));
            }
        }
예제 #25
0
        public void GroupAndFixedSale()
        {
            var cartService = new CartService();
            var cart1       = cartService.GetCartFromString(new[] { "apple", "apple", "apple" });
            var cart2       = cartService.GetCartFromString(new[] { "apple", "apple", "apple", "apple" });

            var priceService = new PriceService();
            var priceCatalog = priceService.GetPriceCatalog("{ 'banana': '0.75', 'apple': '1.75', 'orange': '2.50', 'grapefruit': '5.00'}");

            // Buy 1 apple for $1.25
            // OR
            // Buy 2 apples for $2.00
            var sales = new Dictionary <String, List <ISale> > {
                { "apple", new List <ISale> {
                      new GroupSale(2, 2.00m), new SalePrice(1.25m)
                  } }
            };

            // Best combination of 3 apples is $3.25  (2 for $2 + 1 for $1.25)
            Assert.That(priceService.GetPrice(cart1, priceCatalog, sales),
                        Is.EqualTo(3.25m));

            // Best combination of 4 apples is $4 (2 for $2, twice)
            Assert.That(priceService.GetPrice(cart2, priceCatalog, sales),
                        Is.EqualTo(4.00m));
        }
예제 #26
0
        public void Edit_Item_With_Price()
        {
            ItemCtrl itemCtrl = new ItemCtrl();
            ItemDb   itemDb   = new ItemDb();
            //Setup

            ItemService  itemService  = new ItemService();
            PriceService priceService = new PriceService();

            //Act
            JustFeastDbDataContext db = new JustFeastDbDataContext();
            var testItem  = itemService.GetItem(1000000);
            var testPrice = priceService.GetLatestPrice(1000000);

            ModelLibrary.Item newItemUpdated = new ModelLibrary.Item
            {
                Id          = 1000000,
                Name        = "testNameUpdated",
                Description = "testDescrUpdated",
                Price       = testPrice
            };
            priceService.UpdatePrice(testPrice, 1000000);
            itemService.UpdateItem(newItemUpdated, 1000000, 1000000);

            priceService.UpdatePrice(testPrice, 1000000);

            //Assert
            Assert.IsFalse(testItem.Name == "testNameUpdated");
        }
예제 #27
0
        public void AboveThresholdSale()
        {
            var cartService = new CartService();
            var cart1       = cartService.GetCartFromString(new[] { "apple", "apple", "apple" });                            // 3
            var cart2       = cartService.GetCartFromString(new[] { "apple", "apple", "apple", "apple" });                   // 4
            var cart3       = cartService.GetCartFromString(new[] { "apple", "apple", "apple", "apple", "apple", "apple" }); // 6

            var priceService = new PriceService();
            var priceCatalog = priceService.GetPriceCatalog("{ 'banana': '0.75', 'apple': '1.75', 'orange': '2.50', 'grapefruit': '5.00'}");

            // Buy 4 or more apples for $0.50 each
            var sales = new Dictionary <String, List <ISale> > {
                { "apple", new List <ISale> {
                      new AboveThresholdSale(4, 0.50m)
                  } }
            };

            // This is under the threshold, no deal
            Assert.That(priceService.GetPrice(cart1, priceCatalog, sales),
                        Is.EqualTo(1.75m * 3));

            // At the threshold
            Assert.That(priceService.GetPrice(cart2, priceCatalog, sales),
                        Is.EqualTo(0.50m * 4));

            // Above the threshold
            Assert.That(priceService.GetPrice(cart3, priceCatalog, sales),
                        Is.EqualTo(0.50m * 6));
        }
예제 #28
0
        protected override async Task <bool> DoVerifyEntity(Bill entity)
        {
            if (!await PriceService.IsExist(entity.PriceId))
            {
                throw new EntityNotFoundException($"PriceId:{entity.PriceId} doesn't exist.", "Price");
            }

            if (!await BasketService.IsExist(entity.BasketId))
            {
                throw new EntityNotFoundException($"BasketId:{entity.BasketId} doesn't exist.", "Basket");
            }

            if (!Enumerable.Range(0, 100).Contains(entity.CommissionPercentage))
            {
                throw new ArgumentOutOfRangeException(
                          "CommissionPercentage",
                          $"The available range for percente is 0 to 100. CommissionPercentage:{entity.CommissionPercentage} is out of range.");
            }

            if (!entity.DegreeOfDifficulty.InRange(MinDegreeOfDifficulty, MaxDegreeOfDifficulty))
            {
                throw new ArgumentOutOfRangeException(
                          "DegreeOfDifficulty",
                          $"The available range for degreeOfDifficulty is {MinDegreeOfDifficulty} to {MaxDegreeOfDifficulty}. DegreeOfDifficulty:{entity.DegreeOfDifficulty} is out of range.");
            }

            return(true);
        }
예제 #29
0
        public async Task GetPricesTest()
        {
            var request  = new PriceListRequest(this.connectionSettings.AccessToken, this.connectionSettings.ClientSecret);
            var response = await PriceService.GetPricesAsync(request, "A");

            Assert.IsTrue(response.Data.Count() > 0);
        }
        public void Price_With_Three_Criterias()
        {
            //Arrange
            decimal basePrice  = 100m;
            decimal bonusPrice = 10m;

            _mockPriceRepository.Setup(x => x.GetPrice(PriceKeys.Base_Price)).Returns(basePrice);
            _mockPriceRepository.Setup(x => x.GetPrice(PriceKeys.Followers_Bonus_Price)).Returns(bonusPrice);
            _mockPriceRepository.Setup(x => x.GetPrice(PriceKeys.Public_Repositories_Bonus_Price)).Returns(bonusPrice);
            _mockPriceRepository.Setup(x => x.GetPrice(PriceKeys.Stars_Bonus_Price)).Returns(bonusPrice);
            //Act
            //sut means subject under test
            var sut = new PriceService(_mockPriceRepository.Object);

            PricingCriteria criteria = new PricingCriteria()
            {
                Followers          = 15,
                Stars              = 30,
                PublicRepositories = 10,
            };

            decimal output = sut.CalculateDeveloperPrice(criteria);

            //Assert
            Assert.AreEqual(output, 650);
        }
예제 #31
0
 public SearchController(ProjectService projectService,
     ProjectTypeService projectTypeService,
     AreaService areaService,
     PriceService priceService)
 {
     _ProjectService = projectService;
     _ProjectTypeService = projectTypeService;
     _AreaService = areaService;
     _PriceService = priceService;
 }
예제 #32
0
        public Controller(CountryService countryService, CompanyService companyService, DeliveryService deliveryService, PriceService priceService, RouteService routeService, LocationService locationService, StatisticsService statisticsService, EventService eventService)
        {
            this.countryService = countryService;
            this.companyService = companyService;
            this.deliveryService = deliveryService;
            this.priceService = priceService;
            this.routeService = routeService;
            this.locationService = locationService;
            this.statisticsService = statisticsService;
            this.eventService = eventService;

            Network.Instance.MessageReceived += new Network.MessageReceivedDelegate(OnReceived);
        }
예제 #33
0
 public HomeController(ProjectService projectService,
     ProjectTypeService projectTypeService,
     AreaService areaService,
     PriceService priceService,
     NewsService newsService,
     AdsService adsService,
     ContractorServices contractorServices)
 {
     _ProjectService = projectService;
     _ProjectTypeService = projectTypeService;
     _AreaService = areaService;
     _PriceService = priceService;
     _NewsService = newsService;
     _AdsService = adsService;
     _ContractorServices = contractorServices;
 }
예제 #34
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            // initialise logger
            Logger.Instance.SetOutput(logBox);
            Logger.WriteLine("Server starting..");

            // initialise database
            Database.Instance.Connect();

            // initialise the state object
            currentState = new CurrentState();

            // initialise all the services (they set up the state themselves) and pathfinder
            countryService = new CountryService(currentState);
            companyService = new CompanyService(currentState);
            routeService = new RouteService(currentState);
            var pathFinder = new PathFinder(routeService); // pathfinder needs the RouteService and state
            deliveryService = new DeliveryService(currentState, pathFinder); // DeliveryService needs the PathFinder
            priceService = new PriceService(currentState);
            locationService = new LocationService(currentState);
            eventService = new EventService(currentState);
            statisticsService = new StatisticsService();

            // initialise network
            Network.Network network = Network.Network.Instance;
            network.Start();
            network.Open();

            // create controller
            var controller = new Controller(countryService, companyService, deliveryService, priceService, routeService,
                                            locationService, statisticsService, eventService);

            //BenDBTests(countryService, routeService);
            //SetUpDatabaseWithData();

            /*try
            {
                var priceDH = new PriceDataHelper();

                var standardPrice = new DomesticPrice(Priority.Standard) { PricePerGram = 3, PricePerCm3 = 5 };
                //standardPrice = priceService.CreateDomesticPrice(standardPrice.Priority, standardPrice.PricePerGram, standardPrice.PricePerCm3);

                standardPrice.PricePerCm3 = 8;
                //standardPrice = priceService.UpdateDomesticPrice(standardPrice.ID, standardPrice.Priority, standardPrice.PricePerGram, standardPrice.PricePerCm3);

                var loadedPrice = priceService.GetDomesticPrice(1);
                var prices = priceService.GetAllDomesticPrices();

                var normalPrices = priceService.GetAll();
            }
            catch (DatabaseException er) {
                Logger.WriteLine(er.Message);
                Logger.Write(er.StackTrace);
            }*/
        }