Esempio n. 1
0
        public List <EventCustomerAggregate> GetEventCustomersByIds(long[] eventCustomerIds)
        {
            var customerEventBasicInfoTypedView = new CustomerEventBasicInfoTypedView();
            var bucket = new RelationPredicateBucket(CustomerEventBasicInfoFields.EventCustomerId == eventCustomerIds);

            using (var myAdapter = PersistenceLayer.GetDataAccessAdapter())
            {
                myAdapter.FetchTypedView(customerEventBasicInfoTypedView, bucket, false);
            }
            return(_factory.CreateAggregatesFromTypedViewCollection(customerEventBasicInfoTypedView));
        }
Esempio n. 2
0
        public EventCustomerAggregate GetRegisteredEvent(long customerId, long eventId)
        {
            var customerEventBasicInfoTypedView = new CustomerEventBasicInfoTypedView();
            var bucket = new RelationPredicateBucket(CustomerEventBasicInfoFields.EventId == eventId);

            bucket.PredicateExpression.AddWithAnd(CustomerEventBasicInfoFields.CustomerId == customerId);
            using (var myAdapter = PersistenceLayer.GetDataAccessAdapter())
            {
                myAdapter.FetchTypedView(customerEventBasicInfoTypedView, bucket, false);
            }
            return(_factory.CreateAggregatesFromTypedViewCollection(customerEventBasicInfoTypedView).FirstOrDefault());
        }
Esempio n. 3
0
        private List <EventCustomerAggregate> FetchEventCustomerInformation(long salesRepId, DateRange eventDateRange)
        {
            var customerEventBasicInfoTypedView = new CustomerEventBasicInfoTypedView();
            var bucket = new RelationPredicateBucket(CustomerEventBasicInfoFields.AssignedToOrgRoleUserId == salesRepId);

            if (eventDateRange != null)
            {
                if (eventDateRange.StartDate.HasValue)
                {
                    bucket.PredicateExpression.Add(CustomerEventBasicInfoFields.EventDate >=
                                                   eventDateRange.StartDate.Value);
                }
                if (eventDateRange.EndDate.HasValue)
                {
                    bucket.PredicateExpression.Add(CustomerEventBasicInfoFields.EventDate <=
                                                   eventDateRange.EndDate.Value.GetEndOfDay());
                }
            }
            using (var myAdapter = PersistenceLayer.GetDataAccessAdapter())
            {
                myAdapter.FetchTypedView(customerEventBasicInfoTypedView, bucket, false);
            }
            return(_factory.CreateAggregatesFromTypedViewCollection(customerEventBasicInfoTypedView));
        }
Esempio n. 4
0
 public void TearDown()
 {
     _eventBasicInfoTypedView = null;
 }
Esempio n. 5
0
 public void SetUp()
 {
     _eventBasicInfoTypedView = new CustomerEventBasicInfoTypedView();
 }
Esempio n. 6
0
        public List <EventCustomerAggregate> CreateAggregatesFromTypedViewCollection
            (CustomerEventBasicInfoTypedView customerEventBasicInfoTypedView)
        {
            if (customerEventBasicInfoTypedView == null)
            {
                throw new ArgumentNullException("customerEventBasicInfoTypedView",
                                                "CustomerEventBasicInfoTypedView given cannot be null.");
            }
            var eventCustomers = new List <EventCustomerAggregate>();

            if (customerEventBasicInfoTypedView.Count == 0)
            {
                return(eventCustomers);
            }

            var currentEventCustomerId          = customerEventBasicInfoTypedView.First().EventCustomerId;
            var eventCustomersByEventCustomerId = new List <CustomerEventBasicInfoRow>();

            foreach (var customerEventInfo in (customerEventBasicInfoTypedView.OrderBy(c => c.EventCustomerId)))
            {
                if (customerEventInfo.EventCustomerId != currentEventCustomerId)
                {
                    eventCustomersByEventCustomerId.Clear();
                    currentEventCustomerId = customerEventInfo.EventCustomerId;
                }

                if (!customerEventInfo.IsPodActive)
                {
                    continue;
                }

                bool skip = false;
                foreach (var customerEventBasicInfoRow in eventCustomersByEventCustomerId)
                {
                    if (customerEventInfo.EventName == customerEventBasicInfoRow.EventName &&
                        customerEventInfo.DrOrCr == customerEventBasicInfoRow.DrOrCr &&
                        customerEventInfo.PaymentTotalAmount == customerEventBasicInfoRow.PaymentTotalAmount)
                    {
                        skip = true;
                        break;
                    }
                }

                if (skip)
                {
                    continue;
                }
                eventCustomersByEventCustomerId.Add(customerEventInfo);

                EventCustomerAggregate eventCustomer = GetEventCustomerAggregateFromTypedViewRow(customerEventInfo);
                var customerInfoForEventCustomerId   = eventCustomers.Where(e => e.EventCustomerId == eventCustomer.EventCustomerId);
                int multiplier = customerEventInfo.DrOrCr ? -1 : 1;
                if (customerInfoForEventCustomerId.Count() > 0)
                {
                    customerInfoForEventCustomerId.Single().PaymentAmount += eventCustomer.PaymentAmount * multiplier;
                    continue;
                }
                eventCustomer.PaymentAmount *= multiplier;
                eventCustomers.Add(eventCustomer);
            }
            return(eventCustomers);
        }