예제 #1
0
        public void OnNewButtonClick()
        {
            EnsureState();
            var order    = _orderFactory.Create();
            var editView = _viewFactory.CreateOrderEditView(order);

            editView.Show();
            _dataBinder.BindUI(this);
        }
예제 #2
0
        public OrderRegisterResult Register(OrderRegisterCommand command)
        {
            using (var transaction = new TransactionScope())
            {
                var order = orderFactory.Create(command.orderNumber, command.orderDate, command.address, command.items);
                orderRepository.Save(order);

                transaction.Complete();

                return(new OrderRegisterResult(order.Id));
            }
        }
        public override void Execute()
        {
            TypedResult = new NewOrderItemResult();
            var supplier = suppliersRepository.GetSupplierByName(SupplierName);

            if (supplier == null)
            {
                throw new AppException(ErrorCodes.Supplier.UnknownSupplier);
            }

            var order = orderRepository.GetActiveOrder(supplier);

            if (order == null)
            {
                order          = orderFactory.Create(supplier);
                order.Supplier = supplier;
                orderRepository.Add(order);

                TypedResult.OrderCreated = true;
            }
            else
            {
                if (order.Items == null)
                {
                    order.Items = new List <OrderItem>();
                }
            }

            var user = GetUser();

            var orderItem = orderItemFactory.Create(order);

            orderItem.AuditInfo = AuditInfo;
            orderItem.User      = user;
            orderItem.Content   = OrderContent;

            order.Items.Add(orderItem);
            TypedResult.OrderItem = orderItem;
            base.Execute();
        }
예제 #4
0
        public void Execute(CreateOrderModel model)
        {
            var dateTime = _dateTimeService.GetDateTimeUtc();
            var customer = _orderRepositoryFacade.GetCustomer(model.CustomerId)
                           ?? new Customer {
                UserId = model.CustomerId
            };
            var shopItems = _orderRepositoryFacade.GetCartItems(model.ShoppingCartId);

            var order = _orderFactory.Create(dateTime, customer, shopItems);

            _orderRepositoryFacade.AddOrder(order);

            _clearShoppingCartCommand.Execute(model.ShoppingCartId);

            _unitOfWork.Save();

            foreach (var shopItem in shopItems)
            {
                _inventoryService.NotifyItemSold(shopItem.Id, shopItem.Amount);
            }
        }
예제 #5
0
        public async Task <Order> ImportOrderAsync(Order order)
        {
            bool success;

            #region Validate
            var validationResult = await _orderIsValidToImportValidator.Validate(order);

            if (validationResult.HasErrorMessage)
            {
                await SendDomainNotifications(validationResult);

                return(_orderFactory.Create(validationResult));
            }
            #endregion

            #region Process
            var importedOrder = _orderFactory.Create(validationResult);
            try
            {
                importedOrder.ImportOrder(
                    new TenantInfoValueObject(UserSessionInfo.TenantInfo.TenantCode),
                    _systemUserFactory.Create(UserSessionInfo),
                    order.OrderDate,
                    order.Code,
                    order.Customer,
                    order.OrderShipping,
                    order.OrderItemCollection
                    );

                success = importedOrder?.Id != Guid.Empty;
            }
            catch (Exception ex)
            {
                _ = await InMemoryBus.SendRaisedExceptionEventAsync(UserSessionInfo, GlobalizationInfo, ex);

                success = false;
            }
            #endregion

            #region Notify
            if (success)
            {
                _ = await InMemoryBus.SendEventAsync(
                    new OrderWasImportedEvent(
                        UserSessionInfo,
                        GlobalizationInfo,
                        validationResult,
                        importedOrder
                        )
                    ).ConfigureAwait(false);
            }
            else
            {
                _ = await InMemoryBus.SendEventAsync(
                    new OrderImportFailedEvent(
                        UserSessionInfo,
                        GlobalizationInfo,
                        validationResult,
                        order
                        )
                    ).ConfigureAwait(false);
            }
            #endregion

            return(importedOrder);
        }
        public void Execute(object parameter)
        {
            var order = _orderFactory.Create();

            _eventManager.RaiseEvent <IEventOrderStarted>(args => args.Order = order);
        }
        public void Handle(CreateOrderCommand command)
        {
            Order o = _orderFactory.Create(command.Id, command.ClientId);

            _orderRepository.Save(o);
        }