本文整理汇总了C#中Calendar.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Calendar.Save方法的具体用法?C# Calendar.Save怎么用?C# Calendar.Save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Calendar
的用法示例。
在下文中一共展示了Calendar.Save方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MoveCalendar
/// <summary>
/// Moves the calendar.
/// </summary>
/// <param name="calendar">The calendar.</param>
/// <param name="newFolder">The new folder.</param>
public static void MoveCalendar(Calendar calendar, CalendarFolder newFolder)
{
if (calendar == null)
throw new ArgumentNullException("calendar");
if (newFolder == null)
throw new ArgumentNullException("newFolder");
using (TransactionScope tran = DataContext.Current.BeginTransaction())
{
// Raise Calendar Moving
RaiseEvent(CalendarMoving, calendar, EventArgs.Empty);
calendar.CalendarFolderId = newFolder.PrimaryKeyId.Value;
calendar.Owner = newFolder.Owner;
calendar.Save();
RaiseEvent(CalendarMoved, calendar, EventArgs.Empty);
tran.Commit();
}
}
示例2: CreateCalendar
/// <summary>
/// Creates the calendar.
/// </summary>
/// <param name="folder">The folder.</param>
/// <param name="name">The name.</param>
/// <param name="ownerId">The owner id.</param>
/// <returns></returns>
public static CalendarInfo CreateCalendar(CalendarFolder folder, string name, int? ownerId)
{
if (name == null)
throw new ArgumentNullException("name");
if (folder == null)
throw new ArgumentNullException("folder");
if (!folder.GetTreeService().CurrentNode.IsAttached)
throw new ArgumentException("The folder is dettached from tree.", "folder");
Calendar newItem = null;
using (TransactionScope tran = DataContext.Current.BeginTransaction())
{
// Step 1. Create New Calendar
newItem = new Calendar();
newItem.CalendarFolderId = folder.PrimaryKeyId.Value;
newItem.Title = name;
newItem.Owner = ownerId;
// Raise List Creating Event
RaiseEvent(CalendarCreating, newItem, EventArgs.Empty);
// Add additional parameters
newItem.Save();
// Raise List Created Event
RaiseEvent(CalendarCreated, newItem, EventArgs.Empty);
// Step. Commit Transaction Return new list info
tran.Commit();
}
return new CalendarInfo(newItem, null);
}