Example #1
0
        public void ChangeToLotterySuccess()
        {
            userService.EnterSystem();
            userService.SignIn("Arik1", "123");
            StoreManagementService liorSession = (StoreManagementService)market.GetStoreManagementService(userService, "X");
            Product P = new Product("P1345678", "OBJ", 9, "des");

            ProductToDelete = new StockListItem(4, P, null, PurchaseEnum.Immediate, "S1");
            handler.AddStockListItemToDataBase(ProductToDelete);
            MarketAnswer  ans  = liorSession.ChangeProductPurchaseWayToLottery("OBJ", DateTime.Parse("31/12/2018"), DateTime.Parse("31/12/2020"));
            StockListItem find = handler.GetProductFromStore("X", "OBJ");

            Assert.AreEqual((int)PurchaseEnum.Lottery, (int)find.PurchaseWay);
            LotteryToDelete = handler.GetLotteryByProductID(P.SystemId);
            Assert.IsNotNull(LotteryToDelete);
            Assert.AreEqual((int)StoreEnum.Success, ans.Status);
        }
Example #2
0
        private string GetProductStockInformation(string productID, bool showAll)
        {
            StockListItem stockListItem = storeLogic.GetStockListItembyProductID(productID);

            if (stockListItem == null)
            {
                MarketLog.Log("storeCenter", "product not exists");
                throw new StoreException(StoreEnum.ProductNotFound, "product " + productID + " does not exist in Stock");
            }
            if (stockListItem.PurchaseWay == PurchaseEnum.Lottery && !showAll)
            {
                LotterySaleManagmentTicket managmentTicket =
                    storeLogic.GetLotteryByProductID((productID));
                StockListItem sli = storeLogic.GetStockListItembyProductID(productID);
                if ((managmentTicket.EndDate < MarketYard.MarketDate) ||
                    (managmentTicket.StartDate > MarketYard.MarketDate) ||
                    ((managmentTicket.TotalMoneyPayed == managmentTicket.ProductNormalPrice) && sli.Quantity == 0))
                {
                    return("");
                }
            }
            Discount totalDiscount  = stockListItem.CalcTotalDiscount(_storeName);
            string   discountString = " Discount: {";
            string   product        = stockListItem.Product.ToString();

            if (totalDiscount != null)
            {
                discountString += totalDiscount;
            }
            else
            {
                discountString += "null";
            }
            discountString += "}";
            string purchaseWay = " Purchase Way: " + EnumStringConverter.PrintEnum(stockListItem.PurchaseWay);
            string quanitity   = " Quantity: " + stockListItem.Quantity;
            string result      = product + discountString + purchaseWay + quanitity;

            return(result);
        }