Ejemplo n.º 1
0
        public async Task <OrderDto> CreateOrder(OrderCreateInput input)
        {
            await OrderManager.CheckBuyPermission();

            ProductBoughtContext boughtContext = input.MapTo <ProductBoughtContext>();
            ProductOrder         order         = await OrderManager.CreateOrder(boughtContext);

            return(order.MapTo <OrderDto>());
        }
Ejemplo n.º 2
0
 public ProductBoughtContext Calculate(ProductBoughtContext boughtContext)
 {
     foreach (BoughtItem boughtItem in boughtContext.BoughtItems)
     {
         boughtItem.Price     = boughtItem.Specification.Price;
         boughtItem.Money     = boughtItem.Price * boughtItem.Count;
         boughtContext.Money += boughtItem.Money;
     }
     return(boughtContext);
 }
Ejemplo n.º 3
0
        public OrderConfirmOutput ConfirmOrder(OrderConfirmInput input)
        {
            ProductBoughtContext boughtContext = input.MapTo <ProductBoughtContext>();

            foreach (BoughtItem boughtItem in boughtContext.BoughtItems)
            {
                boughtItem.UserId        = InfrastructureSession.UserId.Value;
                boughtItem.Specification = SpecificationRepository.Get(boughtItem.SpecificationId);
            }
            ProductSalePriceService.Calculate(boughtContext);

            OrderConfirmOutput orderConfirmOutput = boughtContext.MapTo <OrderConfirmOutput>();

            if (input.CustomerInfoId.HasValue)
            {
                orderConfirmOutput.CustomerInfo = CustomerInfoRepository.Get(input.CustomerInfoId.Value).MapTo <CustomerInfoDto>();
            }
            else
            {
                orderConfirmOutput.CustomerInfo = CustomerInfoManager.GetDefaultCustomerInfo(InfrastructureSession.UserId.Value).MapTo <CustomerInfoDto>();
            }
            return(orderConfirmOutput);
        }