void populateFromContext() { ReadOnly = User != null && User.GlobalId != UserContext.Current.CurrentProfile.GlobalId; day = TrainingDayPageContext.Day; if (!ReadOnly && TrainingDayPageContext.Day != null) {//if we are in edit mode we must operate on copy because user can cancel his changes day = TrainingDayPageContext.Day.StandardClone(); } if (commentsControl != null) { commentsControl.Fill(day); } EntryObjectBuilder = ((TrainingDayPageContext)PageContext).Builder; }
public static TrainingDayPageContext CreateTrainingDayWindow(TrainingDayDTO day, UserDTO user, CustomerDTO customer, IEntryObjectBuilderProvider builder = null) { if (day.GlobalId == Constants.UnsavedGlobalId) { day.AllowComments = UserContext.Current.ProfileInformation.Settings.AllowTrainingDayComments; //set default entries for newly created TrainingDay var options = UserContext.Current.Settings.GuiState.CalendarOptions; foreach (var defaultEntry in options.DefaultEntries) { if (defaultEntry.IsDefault == true) { var plugin = PluginsManager.Instance.GetEntryObjectProvider(defaultEntry.ModuleId); if (plugin != null && plugin.EntryObjectType.CanBeManuallyAdded()) { var entry = day.AddEntry(plugin.EntryObjectType); if (builder != null) { builder.EntryObjectCreated(entry); } if (day.TrainingDate.IsFuture()) {//for entries in future set planned status entry.Status = EntryObjectStatus.Planned; } } } } //needed for SizeEntryDTO for example day.ChangeDate(day.TrainingDate); } TrainingDayPageContext context = new TrainingDayPageContext(user, customer, day, builder); return(context); }
public TrainingDayPageContext(UserDTO user, CustomerDTO customer, TrainingDayDTO day, IEntryObjectBuilderProvider builder) : base(user, customer) { this.day = day; this.builder = builder; }