Example #1
0
        /// <summary>
        /// Deletes the link.
        /// </summary>
        /// <param name="link">The link.</param>
        public static void DeleteLink(CalendarFolderLink link)
        {
            if (link == null)
                throw new ArgumentNullException("link");

            using (TransactionScope tran = DataContext.Current.BeginTransaction())
            {
                // Raise Calendar link Delete Event
                RaiseEvent(CalendarLinkDeleting, link, EventArgs.Empty);

                link.Delete();

                RaiseEvent(CalendarLinkDeleted, link, EventArgs.Empty);

                tran.Commit();
            }
        }
Example #2
0
        /// <summary>
        /// Adds the calendar link.
        /// </summary>
        /// <param name="folder">The folder.</param>
        /// <param name="calendar">The calendar.</param>
        /// <returns></returns>
        public static CalendarInfo AddCalendarLink(CalendarFolder folder, Calendar calendar)
        {
            if (folder == null)
                throw new ArgumentNullException("CalendarFolder");
            if (calendar == null)
                throw new ArgumentNullException("Calendar");

            if (!folder.GetTreeService().CurrentNode.IsAttached)
                throw new ArgumentException("The folder is detached from tree.", "folder");

            //Step 1. Determine for already exist link
            CalendarFolderLink[] links = CalendarFolderLink.List(new FilterElement("CalendarId",
                                                                      FilterElementType.Equal,
                                                                      calendar.PrimaryKeyId.Value),
                                                                  new FilterElement("FolderId",
                                                                      FilterElementType.Equal,
                                                                      folder.PrimaryKeyId.Value));
            if (links.Length != 0)
            {
                Calendar cal = new Calendar(links[0].CalendarId);
                return new CalendarInfo(cal, links[0]);
            }

            CalendarFolderLink link = null;
            using (TransactionScope tran = DataContext.Current.BeginTransaction())
            {

                // Step 2. Create New CalendarFolderLink
                link = new CalendarFolderLink();
                link.CalendarId = calendar.PrimaryKeyId.Value;
                link.FolderId = folder.PrimaryKeyId.Value;

                // Raise List Creating Event
                RaiseEvent(CalendarLinkCreating, link, EventArgs.Empty);

                // Add additional parameters
                link.Save();

                // Raise List Created Event
                RaiseEvent(CalendarLinkCreated, link, EventArgs.Empty);

                // Step. Commit Transaction Return new list info
                tran.Commit();

            }

            return new CalendarInfo(calendar, link);
        }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CalendarInfo"/> class.
 /// </summary>
 /// <param name="calendar">The calendar.</param>
 /// <param name="link">The link.</param>
 public CalendarInfo(Calendar calendar, CalendarFolderLink link)
 {
     _calendarLink = link;
     _calendar = calendar;
 }