// Customer
        public async Task <Result <Guid> > CustomerCreateBid(string username, Guid storeId, Guid productId, double newBidPrice)
        {
            Store store = await marketStores.GetStoreById(storeId);

            if (store == null)
            {
                return(new Result <Guid>(new Guid(), true, "Store doesn't exist"));
            }
            if (!store.IsPurchaseKindAvailable(PurchaseKind.Bid))
            {
                return(new Result <Guid>(new Guid(), true, "Bids are not supported in this store"));
            }
            return(await store.CustomerCreateBid(username, storeId, productId, newBidPrice));
        }
예제 #2
0
        private async Task <Guid> AddDiscountAndRuleAsync(string username, Guid storeId, Guid discountId1, Guid discountId2, Guid originalDiscountId = new Guid())
        {
            Store store = await marketStores.GetStoreById(storeId);

            if (store == null)
            {
                return(new Guid());
            }
            var rule1    = store.GetRuleByDiscountId(discountId1);
            var rule2    = store.GetRuleByDiscountId(discountId2);
            var andRule  = Rule.AddTwoRules(rule1, rule2);
            var discount = new ConditionDiscount(store.GetDiscountById(discountId1).Calc, andRule);

            if (!originalDiscountId.Equals(new Guid()))
            {
                discount.Id = originalDiscountId;
            }
            return(store.AddDiscount(username, discount));
        }