Exemplo n.º 1
0
 private void Assert(DomainObjectBase domainObject)
 {
     if (domainObject == null)
     {
         throw new ArgumentNullException(nameof(domainObject));
     }
 }
Exemplo n.º 2
0
        internal void PerformValidation(DomainObjectBase domainObject)
        {
            if(domainObject == null)
                throw new ArgumentNullException("domainObject");

            ((ErrorsContainer<string>)domainObject.Errors).Clear();

            foreach(var property in domainObject.GetType().
                GetProperties(BindingFlags.Public | BindingFlags.Instance))
            {
                foreach(var attr in property.GetAttributes<ValidateAttributeBase>())
                {
                    var factory = this.factories[attr.GetType()];
                    var validator = factory(attr);
                    if(validator == null)
                        continue;

                    string error;
                    if(validator.Validate(domainObject, property, out error))
                        continue;

                    ((ErrorsContainer<string>)domainObject.Errors).Add(property.Name, error);
                }
            }
        }
Exemplo n.º 3
0
        // TODO: These private methods have to be removed from the service, probably pull out a seperate type for these actions.
        private void ApplyPaymentToRefund(IOrderRepository orderRepository, DomainObjectBase creatorOrganizationRoleUser,
                                          DomainObjectBase order, PaymentInstrument paymentInstrument)
        {
            long paymentId = _paymentController.SavePayment(paymentInstrument, "Payment", creatorOrganizationRoleUser.Id);

            orderRepository.ApplyPaymentToOrder(order.Id, paymentId);
        }
Exemplo n.º 4
0
        public Order RefundOrder(IOrderable refundOrderItem, Order order,
                                 DomainObjectBase creatorOrganizationRoleUser, DomainObjectBase forOrganizationRoleUser)
        {
            IOrderController orderController = new OrderController();

            orderController.AddItem(refundOrderItem, 1, forOrganizationRoleUser.Id, creatorOrganizationRoleUser.Id, null,
                                    null, null, RefundItemStatus.Applied.OrderStatusState);

            order = orderController.RefundOrder(order);
            return(order);
        }
Exemplo n.º 5
0
        private void AddTransaction(DomainObjectBase domainObject, Action <DomainObjectBase> operation)
        {
            Assert(domainObject);

            var transaction = new Transaction
            {
                DomainObject = domainObject,
                Operation    = operation
            };

            _transactions.Add(transaction);
        }
Exemplo n.º 6
0
        private OrganizationRoleUser GetOrganizationRoleUsers(DomainObjectBase customer, long organizationRoleUserId, out OrganizationRoleUser forOrganizationRoleUser)
        {
            var organizationRoleUserRepository = new OrganizationRoleUserRepository();
            var creatorOrganizationRoleUser    = organizationRoleUserRepository.GetOrganizationRoleUser(organizationRoleUserId);

            forOrganizationRoleUser = null;
            var orgRoleUsers = organizationRoleUserRepository.GetOrganizationRoleUserCollectionforaUser(customer.Id);

            if (!orgRoleUsers.IsNullOrEmpty())
            {
                forOrganizationRoleUser = orgRoleUsers.Where(org => org.RoleId == (long)Roles.Customer).FirstOrDefault();
            }

            return(creatorOrganizationRoleUser);
        }
Exemplo n.º 7
0
        private Order PlaceOrder(DomainObjectBase forOrganizationRoleUser, DomainObjectBase creatorOrganizationRoleUser, IEnumerable <IOrderable> orderables, EventCustomer eventCustomer, SourceCode sourceCode, ShippingDetail shippingDetail)
        {
            bool indentedLineItemsAdded = false;

            foreach (var orderable in orderables)
            {
                if (!indentedLineItemsAdded && (orderable.OrderItemType == OrderItemType.EventPackageItem || orderable.OrderItemType == OrderItemType.EventTestItem))
                {
                    _orderController.AddItem(orderable, 1, forOrganizationRoleUser.Id, creatorOrganizationRoleUser.Id,
                                             sourceCode,
                                             eventCustomer, shippingDetail, OrderStatusState.FinalSuccess);
                    indentedLineItemsAdded = true;
                }
                else
                {
                    _orderController.AddItem(orderable, 1, forOrganizationRoleUser.Id, creatorOrganizationRoleUser.Id,
                                             OrderStatusState.FinalSuccess);
                }
            }
            return(_orderController.PlaceOrder(OrderType.Retail, creatorOrganizationRoleUser.Id));
        }
Exemplo n.º 8
0
        public Order CancelRefundOrder(IEnumerable <IOrderable> refundOrderItem, Order order, DomainObjectBase creatorOrganizationRoleUser, DomainObjectBase forOrganizationRoleUser)
        {
            IOrderController orderController = new OrderController();

            foreach (var orderable in refundOrderItem)
            {
                orderController.AddItem(orderable, 1, forOrganizationRoleUser.Id, creatorOrganizationRoleUser.Id, null,
                                        null, null, RefundItemStatus.NotApplied.OrderStatusState);
            }

            order = orderController.RefundOrder(order);
            return(order);
        }
Exemplo n.º 9
0
 private void Insert(DomainObjectBase domainObject)
 {
     domainObject.LastModified = GetLastModified();
     Connection.Insert(domainObject);
 }
Exemplo n.º 10
0
 public void RegisterDelete(DomainObjectBase domainObject)
 {
     RegisterDelete(new[] { domainObject });
 }
Exemplo n.º 11
0
 public void RegisterInsert(DomainObjectBase domainObject)
 {
     RegisterInsert(new[] { domainObject });
 }
Exemplo n.º 12
0
 private void Delete(DomainObjectBase domainObject)
 {
     Connection.Delete(domainObject);
 }
Exemplo n.º 13
0
 private void Update(DomainObjectBase domainObject)
 {
     domainObject.LastModified = GetLastModified();
     Connection.Update(domainObject);
 }