Beispiel #1
0
        public Event GetEventDetails(int eventId)
        {
            Customer eventCustomer = Exigo.GetCustomerByIDandType(eventId, CustomerTypes.Party);

            //using (var context = Exigo.Sql())
            //{
            //    var sql = string.Format("exec GetCustomerByIDandType {0}, {1}", eventId, CustomerTypes.Party);
            //    eventCustomer = context.Query<Customer>(sql).FirstOrDefault();
            //}

            //if (null == eventCustomer)
            //{
            //    throw new ApplicationException("The provided event ID does not exist.");
            //}

            var eventCustomerSiteResponse = Exigo.GetCustomerSite(eventId);

            var eventCustomerEx = Exigo.GetCustomerExtendedDetails(eventId, (int)CustomerExtendedGroup.PartyDetails).FirstOrDefault();

            var creator           = new Customer();
            int creatorCustomerId = 0;

            if (int.TryParse(eventCustomerEx.Field5, out creatorCustomerId))
            {
                creator          = Exigo.GetCustomerByIDandType(creatorCustomerId, CustomerTypes.IndependentStyleAmbassador);
                creator.WebAlias = Exigo.GetCustomerWebAlias(creator.CustomerID);
            }

            var host           = new Customer();
            int hostCustomerId = 0;

            if (int.TryParse(eventCustomerEx.Field6, out hostCustomerId))
            {
                host = Exigo.GetCustomer(hostCustomerId);
            }

            // Retrieve the party sales total
            var salesTotal = GetPointAccountBalance(eventId, PointAccounts.PartySalesTotal);

            // Retieve the Host' rewards point accounts
            var pointAccounts = GetHostRewardPointAccounts(eventId);

            //var bookingRewards = GetBookingRewards();

            //int bookingRewardsOwnerId = 0;
            //int.TryParse(eventCustomerEx.Field7, out bookingRewardsOwnerId);

            // Create Missing Host Specials
            //CreateMissngHostSpecials(eventCustomerEx);


            var @event = new Event()
            {
                Id                 = eventCustomer.CustomerID,
                Name               = eventCustomer.FirstName,
                Location           = eventCustomer.MainAddress,
                Creator            = creator,
                Host               = host,
                TotalSales         = salesTotal,
                EventPointAccounts = null != pointAccounts?pointAccounts.ToArray() : null,
                                         //EventBookingRewards = bookingRewards,
                                         //BookingRewardsOwnerId = bookingRewardsOwnerId,
                                         WebAlias      = eventCustomerSiteResponse.WebAlias,
                                         StartDate     = Convert.ToDateTime(eventCustomerEx.Field1),
                                         ActualDate    = Convert.ToDateTime(eventCustomerEx.Field2),
                                         EventStatus   = eventCustomer.CustomerStatusID == 0 ? "Close" : Convert.ToDateTime(eventCustomerEx.Field4) < DateTime.Now ? "Close" : "Open",
                                         CloseDate     = Convert.ToDateTime(eventCustomerEx.Field3),
                                         LockoutDate   = Convert.ToDateTime(eventCustomerEx.Field4),
                                         DeletedEvents = eventCustomer.CustomerStatusID == 0?true:false,
                                         //HostSpecialReward = (HostSpecialDiscount)eventCustomerEx,
            };

            if ((@event.LockoutDate - @event.CloseDate).TotalDays <= 2.00)
            {
                @event.LockoutDate = @event.CloseDate.AddDays(7);
            }
            return(@event);
        }