Пример #1
0
        public Purchase ConvertBasketToSale(HttpContextBase context, IUserInfo user, IBasket basket, decimal taxRate, string saleCodePrefix)
        {
            UserStatus status = UserStatus.None;

            // if we have a user that has not yet been created, create them
            if (!_securityService.Exists(user.Identity.Name))
            {
                status = _securityService.CreateUser(user);

                if (status != UserStatus.Success)
                {
                    throw new SecurityException($"Unable to create user for sale: {_securityService.StatusMessage(status)}");
                }
            }

            // save it to the datasource so it can be used in the sale
            SaveBasket(user, basket);

            // create sale
            SaleFlags  flags = (basket.Delivery.DeliveryType == DeliveryType.Address ? SaleFlags.Delivery : SaleFlags.CollectionOnly) | SaleFlags.Created;
            SaleEntity sale  = _productDataProvider.CreateAndReturnSale(user.GetUniqueId <Guid>(), flags, taxRate, string.Concat(saleCodePrefix, GenerateSaleCode()), null);

            ClearBasket(context, user, emptyDatasource: false); // clear the basket (leave the basket intact in the datasource - this binds the sale)

            Purchase purchase = _checkoutProvider.CreateSale(sale);

            purchase.UserStatus = status;

            return(purchase);
        }
Пример #2
0
 public Purchase(SaleEntity sale)
 {
     Sale = sale;
 }
Пример #3
0
 public Purchase(SaleEntity sale, string url)
     : this(sale)
 {
     Url = url;
 }
Пример #4
0
 /// <summary>
 /// Sets a particular sale flag.
 /// </summary>
 /// <param name="sale"></param>
 /// <param name="flags"></param>
 /// <returns></returns>
 public void SetSaleFlags(SaleEntity sale, SaleFlags flags)
 {
     SetSaleFlags(sale.SaleId, flags);
     sale.SaleFlags &= flags;
 }
Пример #5
0
 /// <summary>
 /// If using a merchant, we may need to confirm the amount requested to pay was actually paid and nothing is outstanding.
 /// </summary>
 /// <param name="sale"></param>
 /// <param name="amount"></param>
 /// <returns>Outstanding amount</returns>
 public decimal ChargeAmount(SaleEntity sale, decimal amount)
 {
     return(_productDataProvider.ChargeAmount(sale, amount));
 }
Пример #6
0
 /// <summary>
 /// Routine to handle updating the entire value of the sale flags (mainly used for order status changes)
 /// </summary>
 /// <param name="sale"></param>
 /// <param name="flags"></param>
 public void UpdateSaleFlags(SaleEntity sale, SaleFlags flags)
 {
     UpdateSaleFlags(sale.SaleId, flags);
 }