/// <summary>
 /// Deprecated Method for adding a new object to the AppointmentResources EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToAppointmentResources(AppointmentResource appointmentResources)
 {
     base.AddObject("AppointmentResources", appointmentResources);
 }
 /// <summary>
 /// Create a new AppointmentResources object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="sqlAppointmentId">Initial value of the SqlAppointmentId property.</param>
 /// <param name="resourceId">Initial value of the ResourceId property.</param>
 public static AppointmentResource CreateAppointmentResources(global::System.Int32 id, global::System.Guid sqlAppointmentId, global::System.Int32 resourceId)
 {
     AppointmentResource appointmentResources = new AppointmentResource();
     appointmentResources.Id = id;
     appointmentResources.SqlAppointmentId = sqlAppointmentId;
     appointmentResources.ResourceId = resourceId;
     return appointmentResources;
 }
 private bool FilterAppointmentResources(AppointmentResource entity)
 {
     return (entity.SqlAppointmentId == this.Id);
 }
 private void DetachAppointmentResources(AppointmentResource entity)
 {
     entity.SqlAppointments = null;
 }
 private void AttachAppointmentResources(AppointmentResource entity)
 {
     entity.SqlAppointments = this;
 }
예제 #6
0
        void Scheduler_AppointmentEdited(object sender, AppointmentEditedEventArgs e)
        {
            var editApp = e.Appointment as Appointment;
            SqlAppointment sqlAppointmentToEdit = domainContext.SqlAppointments.Single(a => a.Id.ToString().Equals(editApp.UniqueId));
            sqlAppointmentToEdit.Start = editApp.Start;
            sqlAppointmentToEdit.End = editApp.End;
            sqlAppointmentToEdit.Subject = editApp.Subject;
            sqlAppointmentToEdit.Body = editApp.Body;
            sqlAppointmentToEdit.Location = editApp.Location;
            sqlAppointmentToEdit.IsAllDayEvent = editApp.IsAllDayEvent;
            sqlAppointmentToEdit.Url = editApp.Url;
            sqlAppointmentToEdit.Importance = editApp.Importance.ToString();
            sqlAppointmentToEdit.TimeMarker = editApp.TimeMarker.ToString();

            // set the RecurrencePattern and reset the exceptions
            if (editApp.IsRecurring())
            {
                sqlAppointmentToEdit.RecurrencePattern = RecurrencePatternHelper.RecurrencePatternToString(editApp.RecurrenceRule.Pattern);

                if (editApp.RecurrenceRule.Exceptions.Count() == 0)
                {
                    foreach (var exception in sqlAppointmentToEdit.SqlAppointments1)
                    {
                        this.domainContext.SqlAppointments.Remove(exception);
                    }
                }
            }
            else
            {
                // first delete all cascading exception appointments
                foreach (var exception in sqlAppointmentToEdit.SqlAppointments1)
                {
                    this.domainContext.SqlAppointments.Remove(exception);
                }
                sqlAppointmentToEdit.RecurrencePattern = null;
            }

            // Add new resources
            foreach (Telerik.Windows.Controls.Resource resource in editApp.Resources)
            {
                if (sqlAppointmentToEdit.AppointmentResources.Count(ar => ar.Resource.Name == resource.ResourceName) == 0)
                {
                    AppointmentResource appResource = new AppointmentResource();
                    appResource.Id = -1;
                    appResource.SqlAppointments = sqlAppointmentToEdit;
                    appResource.Resource = this.domainContext.Resources.Single(r => r.Name == resource.ResourceName);
                    sqlAppointmentToEdit.AppointmentResources.Add(appResource);

                    if (appResource.Resource.ResourceTypes.Name == "Team")
                        editApp.Category = CategoryHelper.MakeCategory(appResource.Resource.Color);
                }
            }
            // Remove old resources
            foreach (AppointmentResource appointmentResource in sqlAppointmentToEdit.AppointmentResources)
            {
                if (editApp.Resources.Count(r => r.ResourceName == appointmentResource.Resource.Name) == 0)
                {
                    this.domainContext.AppointmentResources.Remove(appointmentResource);
                }
            }

            domainContext.SubmitChanges();
        }
예제 #7
0
        void Scheduler_AppointmentCreated(Appointment addedAppointment)
        {
            var sqlAppointment = new SqlAppointment
            {
                Id = new Guid(addedAppointment.UniqueId),
                Start = addedAppointment.Start,
                End = addedAppointment.End,
                Subject = addedAppointment.Subject,
                Body = addedAppointment.Body,
                IsAllDayEvent = addedAppointment.IsAllDayEvent,
                Location = addedAppointment.Location,
                Url = addedAppointment.Url,
                Type = (int)AppointmentType.Regular,
                TimeZoneString = addedAppointment.TimeZone.ToString(),
                Importance = addedAppointment.Importance.ToString(),
                RecurrencePattern = addedAppointment.IsRecurring() ?
                                    RecurrencePatternHelper.RecurrencePatternToString(addedAppointment.RecurrenceRule.Pattern) :
                                    null,
            };

            foreach (var resource in addedAppointment.Resources)
            {
                var appResource = new AppointmentResource();
                appResource.Id = -1;
                appResource.SqlAppointments = sqlAppointment;
                appResource.Resource = this.domainContext.Resources.Single(r => r.Name == resource.ResourceName);
                sqlAppointment.AppointmentResources.Add(appResource);

                if (appResource.Resource.ResourceTypes.Name == "Team")
                    addedAppointment.Category = CategoryHelper.MakeCategory(appResource.Resource.Color);
            }
            this.domainContext.SqlAppointments.Add(sqlAppointment);
            (this.Scheduler.AppointmentsSource as ObservableCollection<Appointment>).Add(addedAppointment);
            //this.domainContext.SubmitChanges();
        }