I will start out by saying I am a bit of a noob when it comes to C# and Sitecore, but I am getting better.
I am trying to update our code to use a droplink control for an event item (we'll call it StringEventID), instead of a text field where users entered a GUID string (too many mistakes were made). Instead, we want to use a droplink that shows a list of active events.
We created a new droplink field within the template, called Event ID. It has two data items, Event (name of the event) and EventID (GUID). We added the new field to the existing Event template and it appears in SC as expected, with the droplink showing the event name as key, and guid as the value.
Of course, because we are using a droplink, we have to convert the GUID that comes through, which is only a pointer to the actual value we want, the GUID for the event itself.
Because so much of our code has been written with the filed StringEventID that it is impractical to update all of the code to convert the new GUID into string. What we are hoping to do is in the ViewModel, update the code that originally just passed through the string, to now read the GUID, convert it to string, and then pass it along to the controller as a string.
What is the best way to do this? Based on online research, I have build the following in the concrete model, but I get an error, saying that it does not have the matching return type of string.
[SitecoreType(TemplateId = "{36371859-7FF2-47D0-86F1-1579416AA584}", AutoMap = true)]
public class NetForumEvent : Event, INetForumEvent
{
public MyLinkedItem NetForumID { get; set; }
...
}
[SitecoreType(TemplateId = "{36371859-7FF2-47D0-86F1-1579416AA584}", AutoMap = true)]
public class MyLinkedItem : NetForumEvent, IMyLinkedItem
{
[SitecoreField("Event ID")]
public string EventId
{
get { return Convert.ToString(EventID); }
set
{
string id = Convert.ToString(EventID);
id = value;
}
}
}
In the abstract model, I have:
public interface IMyLinkedItem : INetForumEvent
{
string EventId { get; set; }
}
public interface INetForumEvent : IEvent
{
string NetForumID { get; set; }
The exact error language is:
'NetForumEvent' does not implement interface member 'INetForumEvent.NetForumID'. 'NetForumEvent.NetForumID' cannot implement 'INetForumEvent.NetForumID' because it does not have the matching return type of 'string'.
Many thanks in advance!