This is a migrated thread and some comments may be shown as answers.

Appointment UniqueID

3 Answers 133 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Brian
Top achievements
Rank 1
Veteran
Brian asked on 29 Apr 2020, 04:49 PM

     What is the purpose of the property UniqueID? It's public, so it must be intended for use by the developer. I kind of expected it to be unique for the lifetime of the appointment instance, but the value changes between the Creating and Created events.

 

DateTime.Now.Ticks       UniqueId                                                         Event
637237601642743485    ed93e590-52ca-4101-adcd-4dddadf19a07    Creating
637237601642833259    5ad0d20c-1bea-4825-9006-0075e472680e   Created
637237601642933477    5ad0d20c-1bea-4825-9006-0075e472680e   Editing
637237602458312088    5ad0d20c-1bea-4825-9006-0075e472680e   Edited

 

 

public class Appointment : AppointmentBase
{
    public Appointment();
 
    public virtual string Body { get; set; }
    public string Location { get; set; }
    public string UniqueId { get; set; }
    public string Url { get; set; }
 
    public override IAppointment Copy();
    public override void CopyFrom(IAppointment other);
    public override string ToString();
}

 

3 Answers, 1 is accepted

Sort by
0
Vladimir Stoyanov
Telerik team
answered on 04 May 2020, 01:05 PM

Hello Brian,

The UniqueId property is mainly used in the Ical export feature. You can check out this functionality in the Ical example from our demos

That said, I am assuming that this thread is related to the other one you have posted: Appointment.UniqueId Versus SqlAppointments.SqlAppointmentID. Can you check out the referenced in that thread examples and let me know, if they help? 

Regards,
Vladimir Stoyanov
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Brian
Top achievements
Rank 1
Veteran
answered on 06 May 2020, 01:20 PM

Yes, the other post lead to this post. However, the question is still valid. The API documentation doesn't explain the intent of this property. The best I can infer based on the behavior I've seen is the UniqueID property is used internally to differentiate states during creating, editing, or deleting.

Initially I was hoping the ID value would remain consistent over the lifetime of the appointment, would have made loading data from a database relatively straight forward. It would have also conflicted with the data type for unique ID in the database example.

I think it is as simple as this, the Appointment type does not have a property, inherited or otherwise, that can be used by the end user to synchronize a runtime instance with persisted data. Seems odd considering that persisting the data is critical to the function of a scheduling app.

The end user has to create a type that inherits from Appointment just to add a property that can be used for this purpose. Simple enough, just wasn't expected. If Appointment had a property of type 'object' with an appropriate name then end users could use it with whatever unique ID strategy they wanted.

 

Regards

 

0
Vladimir Stoyanov
Telerik team
answered on 08 May 2020, 11:20 AM

Hello Brian,

The reason for the different UniqueId values is that the most base class of the Appointment class implements the IEditableObject interface and has some backup logic, so it can reset the previous value in cases the edit is canceled. In some cases the private field and the getter of the UniqueId property can return different values, because the field may hold the current value but the getter returns the backup value.

Here is some code showing what happens under the hood.

// Appointment.cs
public string UniqueId
{
	get
	{
		return this.Storage<Appointment>().uniqueId;
	}
	set
	{
		var storage = this.Storage<Appointment>();
		if (storage.uniqueId != value)
		{
			storage.uniqueId = value;
			this.OnPropertyChanged(() => this.UniqueId);
		}
	}
}

//EditableObjectBase.cs
protected P Storage<P>() where P : T
{
	return this.IsEditing ? (P)this.Backup : (P)(object)this;
}

Where the Backup property in the Storage method is an object of type IAppointment, holding the original appointment state before the editing has started. 

That said, you can consider using the AppointmentCreated and AppointmentDeleted events. The unique ids there

should be the updated ones in both the field and the property.

I hope you find this information helpful.

Regards,
Vladimir Stoyanov
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
ScheduleView
Asked by
Brian
Top achievements
Rank 1
Veteran
Answers by
Vladimir Stoyanov
Telerik team
Brian
Top achievements
Rank 1
Veteran
Share this question
or