private static void RecalculateTimetableArchive(IRepository<TimetablePartArchiveRecord> TimetableArchiveRepository, ITimetableAppointmentService TimetableAppointmentService, TimetableAppointmentPart TimetableAppointmentPart) { TimetableArchiveRepository.Flush(); // remove all current Timetable archive records var TimetableArchiveRecords = from bar in TimetableArchiveRepository.Table where bar.TimetablePart == TimetableAppointmentPart.TimetablePart.Record select bar; TimetableArchiveRecords.ToList().ForEach(TimetableArchiveRepository.Delete); // get all Timetable appointments for the current Timetable var appointments = TimetableAppointmentService.Get(TimetableAppointmentPart.TimetablePart, VersionOptions.Published); // create a dictionary of all the year/month combinations and their count of appointments that are published in this Timetable var inMemoryTimetableArchives = new Dictionary<DateTime, int>(appointments.Count()); foreach (var appointment in appointments) { if (!appointment.Has<CommonPart>()) continue; var commonPart = appointment.As<CommonPart>(); var key = new DateTime(commonPart.PublishedUtc.Value.Year, commonPart.PublishedUtc.Value.Month, 1); if (inMemoryTimetableArchives.ContainsKey(key)) inMemoryTimetableArchives[key]++; else inMemoryTimetableArchives[key] = 1; } // create the new Timetable archive records based on the in memory values foreach (KeyValuePair<DateTime, int> item in inMemoryTimetableArchives) { TimetableArchiveRepository.Create(new TimetablePartArchiveRecord {TimetablePart = TimetableAppointmentPart.TimetablePart.Record, Year = item.Key.Year, Month = item.Key.Month, AppointmentCount = item.Value}); } }
private void UpdateTimetableAppointmentCount(TimetableAppointmentPart TimetableAppointmentPart) { CommonPart commonPart = TimetableAppointmentPart.As<CommonPart>(); if (commonPart != null && commonPart.Record.Container != null) { TimetablePart TimetablePart = TimetableAppointmentPart.TimetablePart ?? _TimetableService.Get(commonPart.Record.Container.Id, VersionOptions.Published).As<TimetablePart>(); // Ensure the "right" set of published appointments for the Timetable is obtained TimetablePart.ContentItem.ContentManager.Flush(); TimetablePart.AppointmentCount = _TimetableAppointmentService.Get(TimetablePart, VersionOptions.Published).Count(); } }
public static string TimetableAppointmentUnpublish(this UrlHelper urlHelper, TimetableAppointmentPart TimetableAppointmentPart) { return urlHelper.Action("Unpublish", "TimetableAppointmentAdmin", new { TimetableId = TimetableAppointmentPart.TimetablePart.Id, postId = TimetableAppointmentPart.Id, area = "Alois.Timetables" }); }
public static string TimetableAppointment(this UrlHelper urlHelper, TimetableAppointmentPart TimetableAppointmentPart) { return urlHelper.Action("Item", "TimetableAppointment", new { TimetableSlug = TimetableAppointmentPart.TimetablePart.As<IRoutableAspect>().Path, postSlug = TimetableAppointmentPart.As<IRoutableAspect>().GetEffectiveSlug(), area = "Alois.Timetables" }); }
public DateTime? GetScheduledPublishUtc(TimetableAppointmentPart TimetableAppointmentPart) { var task = _publishingTaskManager.GetPublishTask(TimetableAppointmentPart.ContentItem); return (task == null ? null : task.ScheduledUtc); }
public void Unpublish(TimetableAppointmentPart TimetableAppointmentPart) { _contentManager.Unpublish(TimetableAppointmentPart.ContentItem); }
public void Publish(TimetableAppointmentPart TimetableAppointmentPart, DateTime scheduledPublishUtc) { _publishingTaskManager.Publish(TimetableAppointmentPart.ContentItem, scheduledPublishUtc); }
public void Publish(TimetableAppointmentPart TimetableAppointmentPart) { _publishingTaskManager.DeleteTasks(TimetableAppointmentPart.ContentItem); _contentManager.Publish(TimetableAppointmentPart.ContentItem); }
private static void SetModelProperties(BuildShapeContext context, TimetableAppointmentPart TimetableAppointment) { context.Shape.Timetable = TimetableAppointment.TimetablePart; }