Mono Support Way to add calendar events to the repository? (Closed)

Viewed 14489 time(s), 4 post(s), 4/18/2012 4:08:23 PM - by Jeremy
4/18/2012 4:08:23 PM
322 Reputation 36 Total posts

Can anyone tell me the function to call to save a new event to the calendar event repository?

I have been able to create a new calendar using

repository.CreateCalendar(ownerId, name, slug)<BR>

I am having trouble finding a similar function to create an event that will save into the repository.

I can populate an event like this:

var newEvent = repository.GetNewCalendarEvent(authorId, calendarId);
newEvent.Title =
"Some title";
newEvent.Description = "Some
description";
newEvent.AllDay =
true;
newEvent.StartTime =
currentDay;
newEvent.EndTime = currentDay.AddDays(1);

What is the correct way to save a populated event back into the repository?

1
4/18/2012 4:34:49 PM
629 Reputation 83 Total posts

Hi Jeremy,

You're on right track. GetNewCalendarEvent will give you only in-memory instance of new event and it will not save it in database. Also this method will ensure newEvent has all required fields and it's attached to calendar. Sometimes you don't want to save new event to persistent storage at the time of creation, you may need to validate it before saving it. To save it to database you need to use generic SaveEntity method, you just need to add this code after populating your event

repository.SaveEntity(newEvent);

If you don't have create or save method for entity you can use generic SaveEntity on any repository to save it to persistent storage.

2
4/18/2012 11:03:51 PM
322 Reputation 36 Total posts

Thank you. That was the missing piece of the puzzle. I have been able to save the new event back into the repository now and have seen it in the database table.

3
1/17/2014 4:35:43 PM
20 Reputation 2 Total posts

Hello. Can anyone tell me how to save recurring events on the calendar. Thanks in advance ...

4
This is a demo site for MonoX. Please visit Mono Software for more info.