示例#1
0
        public override async Task <WorkflowResult> AddPaymentAsync(decimal amount, Guid userId)
        {
            await _orderStorage.AddPaymentAsync(_order.OrderId, _order.BillId, amount, _dateComponent.ServerDate);

            await _orderHistorization.AddBillingHistorizationAsync(_order.BillId, BillActivityType.PaymentAdded, _dateComponent.ServerDate, userId);

            if (await _orderStorage.IsPaidAsync(_order.OrderId))
            {
                _order.OrderState = new OrderPayedState();
                await _orderHistorization.AddBillingHistorizationAsync(_order.BillId, BillActivityType.Payed, _dateComponent.ServerDate, userId);

                await _orderHistorization.AddOrderHistorizationAsync(_order.OrderId, OrderStatus.Payed, _dateComponent.ServerDate, userId);

                await _userHistorizationComponent.AddUserActivity(_order.OrderId, Enums.UserHistorization.UserActivityType.OrderPayed, _dateComponent.ServerDate, userId);
            }
            else
            {
                await _userHistorizationComponent.AddUserActivity(_order.OrderId, Enums.UserHistorization.UserActivityType.OrderPaymentAdded, _dateComponent.ServerDate, userId);
            }
            return(_successResult);
        }
示例#2
0
        public override async Task <WorkflowResult> CreateAsync(
            Guid excursionId,
            KeyValuePair <int, int>[] aditionalServices,
            KeyValuePair <int, int>[] orderDetails,
            Guid userId)
        {
            if (excursionId == Guid.Empty || orderDetails == null || aditionalServices == null)
            {
                return(_missingIncorrectParameters);
            }

            if (!orderDetails.Any() || !orderDetails.All(detail => detail.Key > 0 && detail.Value > 0))
            {
                return(_missingOrderDetails);
            }

            if (aditionalServices.Any() && !aditionalServices.All(detail => detail.Key > 0 && detail.Value > 0))
            {
                return(_missingAditionalService);
            }

            if (!await _orderStorage.CreateOrderHeaderAsync(
                    _order.OrderId, _order.CustomerId, excursionId, _dateComponent.ServerDate))
            {
                return(_createOrderHeaderError);
            }

            await _orderHistorization.AddOrderHistorizationAsync(
                _order.OrderId, OrderStatus.Confirmed, _dateComponent.ServerDate, userId);

            if (!await _orderStorage.AddOrderDetailsAsync(
                    _order.OrderId,
                    aditionalServices,
                    orderDetails))
            {
                return(_createOrderDetailsError);
            }

            if (!await _orderStorage.AddBillingAsync(_order.OrderId, _order.BillId, _order.CustomerId, _dateComponent.ServerDate))
            {
                return(_createOrderAddBillingError);
            }

            await _orderHistorization.AddBillingHistorizationAsync(_order.BillId, BillActivityType.BillCreated, _dateComponent.ServerDate, userId);

            await _userHistorizationComponent.AddUserActivity(_order.OrderId, Enums.UserHistorization.UserActivityType.OrderCreated, _dateComponent.ServerDate, userId);

            _order.OrderState = new OrderConfirmedState(_order, _orderHistorization, _orderStorage, _dateComponent, _userHistorizationComponent);

            return(_successResult);
        }