Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            RedirectToLoginIfAnonymous();

            if (Page.IsPostBack)
            {
                return;
            }

            if (Contact == null)
            {
                return;
            }

            if (Contact.GetAttributeValue <int?>("adx_timezone") == null)
            {
                return;
            }

            var appointmentFetchXml = string.Format(AppointmentFetchXmlFormat, AppointmentStatusScheduled, DateTime.UtcNow, Contact.GetAttributeValue <Guid>("contactid"));

            var response = (RetrieveMultipleResponse)ServiceContext.Execute(new RetrieveMultipleRequest
            {
                Query = new FetchExpression(appointmentFetchXml)
            });

            if (response == null || response.EntityCollection == null || response.EntityCollection.Entities == null)
            {
                return;
            }

            var usersMinutesFromGmt = GetUsersMinutesFromGmt(Contact.GetAttributeValue <int?>("adx_timezone").GetValueOrDefault(), ServiceContext);

            var appointments = response.EntityCollection.Entities.Select(a => new
            {
                scheduledStart = a.GetAttributeValue <DateTime?>("scheduledstart").GetValueOrDefault().ToUniversalTime().AddMinutes(usersMinutesFromGmt),
                scheduledEnd   = a.GetAttributeValue <DateTime?>("scheduledend").GetValueOrDefault().ToUniversalTime().AddMinutes(usersMinutesFromGmt),
                serviceType    = a.GetAttributeValue <EntityReference>("serviceid") == null ? string.Empty : a.GetAttributeValue <EntityReference>("serviceid").Name,
                dateBooked     = a.GetAttributeValue <DateTime>("createdon").ToUniversalTime().AddMinutes(usersMinutesFromGmt),
                serviceId      = a.GetAttributeValue <Guid>("activityid")
            });

            BookedAppointments.DataSource = appointments;
            BookedAppointments.DataBind();
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            RedirectToLoginIfAnonymous();

            if (Page.IsPostBack)
            {
                return;
            }

            if (Contact == null)
            {
                return;
            }

            if (Contact.Adx_TimeZone == null)
            {
                return;
            }

            var usersMinutesFromGmt = GetUsersMinutesFromGmt(Contact.Adx_TimeZone, ServiceContext);

            var appointments =
                from serviceActivity in ServiceContext.ServiceAppointmentSet.ToList()
                from customer in serviceActivity.Customers
                let partyLookup = customer.PartyId
                                  where partyLookup != null && partyLookup.Id == Contact.ContactId && serviceActivity.ScheduledStart > DateTime.UtcNow && serviceActivity.StateCode == (int)Enums.ServiceAppointmentState.Scheduled
                                  orderby serviceActivity.ScheduledStart.GetValueOrDefault() ascending
                                  select new
            {
                scheduledStart = serviceActivity.ScheduledStart.GetValueOrDefault().ToUniversalTime().AddMinutes(usersMinutesFromGmt),
                scheduledEnd   = serviceActivity.ScheduledEnd.GetValueOrDefault().ToUniversalTime().AddMinutes(usersMinutesFromGmt),
                serviceType    = serviceActivity.service_service_appointments.Name,
                dateBooked     = serviceActivity.CreatedOn.GetValueOrDefault().ToUniversalTime().AddMinutes(usersMinutesFromGmt),
                serviceId      = serviceActivity.ActivityId
            };

            BookedAppointments.DataSource = appointments;
            BookedAppointments.DataBind();
        }