예제 #1
0
        public void GetByIdShouldReturnOrderById()
        {
            var options = new DbContextOptionsBuilder <BookStoreDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;
            //

            var dbContext = new BookStoreDbContext(options);

            var incomeMoneyService = new IncomeMoneyService(dbContext);

            var purchase = new IncomeMoney
            {
                UserId             = "D220E7A5-D7A8-465F-A923-066873664B4F",
                TotalMoney         = 12.6M,
                ProductId          = 6,
                Quantity           = 2,
                PaymentMethod      = "Card",
                AddressDelivery    = "Razgrad bul.Bulgaria 13 A",
                DateTimeOfPurchase = DateTime.Now
            };

            dbContext.IcIncomeMonies.Add(purchase);
            dbContext.SaveChanges();


            var returnPurchaseFromDb = incomeMoneyService.GetById(purchase.Id);

            Assert.True(returnPurchaseFromDb.UserId == "D220E7A5-D7A8-465F-A923-066873664B4F");
        }
예제 #2
0
        public void Create(string userId, decimal totalMoney, int productId, int quantity, string paymentMethod,
                           string addressDelivery, DateTime dateOfPurchase)
        {
            var income = new IncomeMoney()
            {
                UserId             = userId,
                AddressDelivery    = addressDelivery,
                DateTimeOfPurchase = dateOfPurchase,
                ProductId          = productId,
                PaymentMethod      = paymentMethod,
                Quantity           = quantity,
                TotalMoney         = totalMoney
            };

            _db.IcIncomeMonies.Add(income);

            _db.SaveChanges();
        }