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(); }
public MainWindow() { InitializeComponent(); // Create the 'day controls' for each day and display them on the main grid. _daysInMonth = new List <StackPanel>(); for (int createDays = 0; createDays < 31; createDays++) { _daysInMonth.Add(CreateDayControl(createDays)); } int currentDay = 0; for (int populateRow = 2; populateRow < 8; populateRow++) { for (int populateCol = 0; populateCol < 7; populateCol++) { Grid.SetRow(_daysInMonth[currentDay], populateRow); Grid.SetColumn(_daysInMonth[currentDay], populateCol); MonthViewGrid.Children.Add(_daysInMonth[currentDay]); currentDay++; if (currentDay == 31) { break; } } if (currentDay == 31) { break; } } // Create the appointment instances. _bookedAppointments = new BookedAppointments(); // Initialise the calendar by getting the current month and displaying all the appointments. _currentMonthDisplay = DateTime.Now.Month; txtMonthName.Text = GetMonthName(_currentMonthDisplay); ShowMonthsAppointments(_currentMonthDisplay); }
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(); }