示例#1
0
        private static Task GetProductBasePricesRx()
        {
            var productService = new ProductPriceService();

            var stoperRx = new Stoper();

            productService
            .GetProductBasePricesRx()
            .Subscribe(
                x => HappyConsole.WriteCyanLine($"{x.ProductId,2} - {x.Price,5} - {x.IsActive}"),
                () => stoperRx.Dispose());

            return(Task.CompletedTask);
        }
示例#2
0
        private static async Task GetProductBasePrice()
        {
            var productService = new ProductPriceService();

            using (var stoper = new Stoper())
            {
                var productPrices = await productService.GetProductBasePrices();

                foreach (var item in productPrices)
                {
                    HappyConsole.WriteBlueLine($"{item.ProductId,2} - {item.Price,5} - {item.IsActive}");
                }
            }
        }
示例#3
0
        public void ProductPriceServiceCRUDTest()
        {
            var context = new NoodleDbContext("NoodleDb");

            context.Init();

            IProductPriceService service = new ProductPriceService(context);

            var id        = Guid.NewGuid();
            var productId = Guid.NewGuid();

            var record = new ProductPrice
            {
                Id           = id,
                ProductId    = productId,
                Price        = 10,
                CurrencyCode = "USD"
            };

            service.Create(record);

            record.Price = 20;

            service.Update(record);

            var record2 = service.GetById(id);

            Assert.AreEqual(record.Id, record2.Id);
            Assert.AreEqual(record.ProductId, record2.ProductId);
            Assert.AreEqual(record.Price, record2.Price);
            Assert.AreEqual(record.CurrencyCode, record2.CurrencyCode);

            service.Delete(record.Id);

            var record3 = service.GetById(id);

            Assert.IsNull(record3);
        }