public async Task <IActionResult> Edit(int id, [Bind("BranchId,ItemId")] BranchItem branchItem) { if (id != branchItem.BranchId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(branchItem); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BranchItemExists(branchItem.BranchId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["BranchId"] = new SelectList(_context.Set <Branch>(), "Id", "Id", branchItem.BranchId); ViewData["ItemId"] = new SelectList(_context.Item, "Id", "Id", branchItem.ItemId); return(View(branchItem)); }
private void ImportBlog() { LogMessage("Reading import file"); string fileLocation = string.Format("{0}\\{1}", ApplicationContext.PackagePath, WordpressXmlFile.Value); List <WpPost> listWordpressPosts = WpImportManager.Import(fileLocation, ImportComments.Checked, ImportCategories.Checked, ImportTags.Checked); LogMessage("Creating blog"); Item root = db.GetItem(litSummaryPath.Text); BranchItem newBlog = db.Branches.GetMaster(Settings.BlogBranchID); BlogHomeItem blogItem = root.Add(ItemUtil.ProposeValidItemName(litSettingsName.Value), newBlog); blogItem.BeginEdit(); blogItem.Email.Field.Value = litSettingsEmail.Value; blogItem.EndEdit(); LogMessage("Importing posts"); LogTotal(listWordpressPosts.Count); WpImportManager.ImportPosts(blogItem, listWordpressPosts, db, (itemName, count) => { LogMessage("Importing entry " + itemName); LogProgress(count); }); }
// // GET: /Branch/ public ActionResult Create() { BranchService objBranch = new BranchService(); BranchItem objItem = new BranchItem(); List<BranchItem> lstBranch = new List<BranchItem>(); int cid = 0; if (Session["CompID"] != null) { cid = Convert.ToInt32(Session["CompID"].ToString()); } lstBranch = objBranch.getBranch(cid); objItem.ListBranch = new List<BranchItem>(); objItem.ListBranch.AddRange(lstBranch); #region Bind DropDown Country List<clsMasterData> lstMasters = new List<clsMasterData>(); lstMasters = objBranch.getCountry(); objItem.ListCon = new List<clsMasterData>(); objItem.ListCon.AddRange(lstMasters); #endregion #region Bind DropDown Comp List<CompanyItem> lstComp = new List<CompanyItem>(); lstComp = objBranch.GetAllComp(); objItem.ListComp = new List<CompanyItem>(); objItem.ListComp.AddRange(lstComp); #endregion ViewBag.Menuid = Request.QueryString["menuId"]; return View(objItem); }
public void UpdateThisOccurrence(UpdateCommandContext context, BranchItem branch) { CalendarActions.DeleteEvent(context.Event.ID, false); CalendarActions.CreateEvent(context.Event, null, context.Options, branch); }
public async Task <IActionResult> PutBranchItem(int id, BranchItem branchItem) { if (id != branchItem.Id) { return(BadRequest()); } _context.Entry(branchItem).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BranchItemExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <BranchItem> > PostBranchItem(BranchItem branchItem) { _context.BranchItem.Add(branchItem); await _context.SaveChangesAsync(); return(CreatedAtAction("GetBranchItem", new { id = branchItem.Id }, branchItem)); }
/// <summary> /// Creates the Site root using the branch template /// </summary> /// <param name="parentItem"></param> /// <param name="database"></param> /// <returns></returns> private Item CreateWebsiteRoot(Item parentItem, Database database) { Item newWebRootItem = null; BranchItem siteRootBranchItem = siteRootBranchTemplateID.Length > 0 ? database.Branches[siteRootBranchTemplateID] : database.Branches[TemplateIDs.Folder]; //Check if branch template exists, else abort pipeline if (siteRootBranchItem != null) { Log.Audit((object)this, "Create Website Root: {0}", new string[1] { AuditFormatter.FormatItem(parentItem) }); using (new SecurityDisabler()) { //txtSiteName will replace the $name standard value defined under branch template when the site is created newWebRootItem = siteRootBranchItem.AddTo(parentItem, txtSiteName.Value); } } else { Context.ClientPage.ClientResponse.Alert(Translate.Text("{0} branch was not found.", (object)siteRootBranchTemplateID)); } return(newWebRootItem); }
public new void Init(Item settings_item, string site_settings_path) { _eventBranch = ((LinkField) (settings_item.Fields[EventMasterField])).TargetItem; _settingsItem = settings_item; base.Init(settings_item, site_settings_path); }
public ActionResult Edit(int id) { BranchService objBranch = new BranchService(); BranchItem objBItem = new BranchItem(); objBItem = objBranch.GetById(id); //Session["Empid"] = objPassItem.EmpId; List<BranchItem> lstBranch = new List<BranchItem>(); objBItem.ListBranch = new List<BranchItem>(); objBItem.ListBranch.AddRange(lstBranch); ViewBag.Menuid = Request.QueryString["menuId"]; #region Bind DropDown Country List<clsMasterData> lstMasters = new List<clsMasterData>(); lstMasters = objBranch.getCountry(); objBItem.ListCon = new List<clsMasterData>(); objBItem.ListCon.AddRange(lstMasters); #endregion #region Bind DropDown Comp List<CompanyItem> lstComp = new List<CompanyItem>(); lstComp = objBranch.GetAllComp(); objBItem.ListComp = new List<CompanyItem>(); objBItem.ListComp.AddRange(lstComp); #endregion return View(objBItem); }
private void Create(Event eventItem, EventList calendar, BranchItem branch) { if (eventItem != null || calendar != null) { Item root = StaticSettings.EventTargetDatabase.GetItem(calendar.ID); if (root == null || SecurityManager.CanWrite(root) != true) { return; } Item parent = StaticSettings.EventTargetDatabase.GetItem(calendar.ID); if (parent != null) { parent = Utilities.CreateDatePath(parent, eventItem.StartDate); } if (SecurityManager.CanWrite(parent) != true || parent == null) { return; } Item child = parent.Add(Utilities.Sanitize(eventItem.Title), branch); eventItem.ID = child.ID.ToString(); eventItem.Save(); PublishUtil.Publishing(eventItem.GetTargetItem(), true, false); } }
public void WithBranches_WhenCalled_SetsItemBranches() { var branches = new BranchItem[0]; Item item = new FakeItem().WithBranches(branches); item.Branches.Should().NotBeNull(); }
public async Task SaveAsync(BranchItem branchItem) { var isNew = branchItem.Id == default(long); _context.Entry(branchItem).State = isNew ? EntityState.Added : EntityState.Modified; await _context.SaveChangesAsync(); }
public int Insert(BranchItem model) { Mapper.CreateMap <BranchItem, Branch_master>(); Branch_master objBranch = Mapper.Map <Branch_master>(model); DbContext.Branch_master.Add(objBranch); return(DbContext.SaveChanges()); }
public int Update(BranchItem model) { Mapper.CreateMap <BranchItem, Branch_master>(); Branch_master objBranch = DbContext.Branch_master.SingleOrDefault(m => m.id == model.id); objBranch = Mapper.Map(model, objBranch); return(DbContext.SaveChanges()); }
public ActionResult DeleteConfirmed(int id) { BranchItem branchItem = db.BranchItems.Find(id); db.BranchItems.Remove(branchItem); db.SaveChanges(); return(RedirectToAction("Index")); }
public BranchItem GetById(int id) { Mapper.CreateMap <Branch_master, BranchItem>(); Branch_master objBranch = DbContext.Branch_master.SingleOrDefault(m => m.id == id); BranchItem objBItem = Mapper.Map <BranchItem>(objBranch); return(objBItem); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Address,City,District")] Branch branch, int[] ItemId) { if (id != branch.Id) { return(NotFound()); } if (ModelState.IsValid) { try { branch.BranchItems = new List <BranchItem>(); branch.BranchItems = await _context.BranchItem .Where(bi => bi.BranchId == branch.Id) .Include(bi => bi.Item) .ToListAsync(); foreach (var i in ItemId) { if (branch.BranchItems.FirstOrDefault(bi => bi.ItemId == i) != null) { continue; } var branchItem = new BranchItem() { BranchId = branch.Id, ItemId = i }; branch.BranchItems.Add(branchItem); var item = await _context.Item.Include(x => x.BranchItems).FirstOrDefaultAsync(x => x.Id == i); item.BranchItems.Add(branchItem); _context.Update(item); _context.Add(branchItem); } _context.Update(branch); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BranchExists(branch.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(branch)); }
protected virtual void RewriteBranchRenderingDataSources(Item item, BranchItem branchTemplateItem, string branchRoot) { var branchBasePath = branchTemplateItem.InnerItem.Paths.FullPath; LayoutHelper.ApplyActionToAllRenderings(item, rendering => { if (string.IsNullOrWhiteSpace(rendering.Datasource)) { return(RenderingActionResult.None); } // note: queries and multiple item datasources are not supported var renderingTargetItem = item.Database.GetItem(rendering.Datasource); if (renderingTargetItem == null) { Log.Warn( "Error while expanding branch template rendering datasources: data source {0} was not resolvable." .FormatWith(rendering.Datasource), this); } // if there was no valid target item OR the target item is not a child of the branch template we skip out if (renderingTargetItem == null || !renderingTargetItem.Paths.FullPath.StartsWith(branchBasePath, StringComparison.OrdinalIgnoreCase)) { return(RenderingActionResult.None); } var relativeRenderingPath = renderingTargetItem.Paths.FullPath.Substring(branchBasePath.Length).TrimStart('/'); relativeRenderingPath = relativeRenderingPath.Substring(relativeRenderingPath .IndexOf('/')); // we need to skip the "/$name" at the root of the branch children var newTargetPath = item.Paths.FullPath + relativeRenderingPath; var newTargetItem = item.Database.GetItem(newTargetPath); // if the target item was a valid under branch item, but the same relative path does not exist under the branch instance // we set the datasource to something invalid to avoid any potential unintentional edits of a shared data source item if (newTargetItem == null) { rendering.Datasource = "INVALID_BRANCH_SUBITEM_ID"; return(RenderingActionResult.None); } rendering.Datasource = newTargetItem.ID.ToString(); return(RenderingActionResult.None); }); if (!item.HasChildren) { return; } item.Children.ToList().ForEach(x => RewriteBranchRenderingDataSources(x, branchTemplateItem, branchRoot)); }
public static Item CreateBranchItem(string newBranchName, Database targetDatabase, string branchTemplateId, string branchBucketId) { Item branchTemplateItem = targetDatabase.GetItem(branchTemplateId); Item branchBucketItem = targetDatabase.GetItem(branchBucketId); BranchItem branchItem = targetDatabase.GetItem(branchTemplateItem.ID); Item branchTargetItem = branchBucketItem.Add(newBranchName.Trim(), branchItem); return(branchTargetItem); }
public static Item CreateItemPath(Item parent, string itemName, BranchItem branch) { Item child = parent.Axes.GetChild(itemName); if (child == null) { return parent.Add(itemName, branch); } return child; }
public EventCommandContext(Event evt, Schedule schedule, Options options, BranchItem branch) { Assert.ArgumentNotNull(evt, "evt"); Event = evt; Schedule = schedule; Options = options; this.branch = branch; }
public ActionResult Edit([Bind(Include = "ID,BranchName,Address,Email,TelephoneNo,ParentInformationID")] BranchItem branchItem) { if (ModelState.IsValid) { db.Entry(branchItem).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(branchItem)); }
public ActionResult Create([Bind(Include = "ID,BranchName,Address,Email,TelephoneNo,ParentInformationID")] BranchItem branchItem) { if (ModelState.IsValid) { db.BranchItems.Add(branchItem); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(branchItem)); }
/// <summary> /// Updates the item links. /// </summary> /// <param name="root">The root.</param> /// <param name="branch">The branch.</param> public virtual void UpdateItemLinks(Item root, BranchItem branch) { Assert.IsTrue(branch.InnerItem.Children.Count == 1, BranchItemShouldHaveTheOnlyChildren); string nameTokenValue = root.Name; Dictionary<ID, string> relativePathMapping = new Dictionary<ID, string>(); this.BuildRelativePath(new StringBuilder(), nameTokenValue, branch.InnerItem.Children.Single(), relativePathMapping); this.UpdateLinks(root, root, relativePathMapping); }
public override void Execute(CommandContext context) { if (context.Items.Length != 1) { return; } Item obj = context.Items[0]; if (!obj.Access.CanCreate()) { SheerResponse.Alert("You do not have permission to create a new item here."); } else { string template = StringUtil.GetString(context.Parameters["template"]); string master = StringUtil.GetString(context.Parameters["master"]); string prompt = StringUtil.GetString(context.Parameters["prompt"]); NameValueCollection parameters = new NameValueCollection(); BranchItem branchItem = (BranchItem)null; TemplateItem templateItem = (TemplateItem)null; if (master.Length > 0) { branchItem = Context.ContentDatabase.Branches[master]; Error.Assert(branchItem != null, "Master \"" + master + "\" not found."); } else if (template.Length > 0) { templateItem = Context.ContentDatabase.Templates[template]; Error.Assert(templateItem != null, "Template \"" + template + "\" not found."); } if (branchItem == null && templateItem == null) { return; } parameters["prompt"] = prompt; parameters["id"] = obj.ID.ToString(); parameters["database"] = obj.Database.Name; if (branchItem != null) { parameters["master"] = branchItem.ID.ToString(); } if (templateItem != null) { parameters["template"] = templateItem.ID.ToString(); } Context.ClientPage.Start((object)this, "Run", parameters); } }
/// <summary> /// Updates the item links. /// </summary> /// <param name="root">The root.</param> /// <param name="branch">The branch.</param> public virtual void UpdateItemLinks(Item root, BranchItem branch) { Assert.IsTrue(branch.InnerItem.Children.Count == 1, BranchItemShouldHaveTheOnlyChildren); string nameTokenValue = root.Name; Dictionary <ID, string> relativePathMapping = new Dictionary <ID, string>(); this.BuildRelativePath(new StringBuilder(), nameTokenValue, branch.InnerItem.Children.Single(), relativePathMapping); this.UpdateLinks(root, root, relativePathMapping); }
/// <summary> /// Create site definition /// </summary> /// <param name="parentItem"></param> /// <param name="database"></param> /// <param name="language"></param> /// <param name="websiteRootItem"></param> private void CreateSiteDefinition(Item parentItem, Database database, string language, Item websiteRootItem) { BranchItem siteDefinitionBranchItem = siteDefinitionBranchTemplateID.Length > 0 ? database.Branches[siteDefinitionBranchTemplateID] : database.Branches[TemplateIDs.Folder]; if (siteDefinitionBranchItem != null) { Log.Audit((object)this, "Create Site Definition:{0}", new string[1] { AuditFormatter.FormatItem(parentItem) }); Item newSiteDefinition = siteDefinitionBranchItem.AddTo(parentItem, txtSiteName.Value); //Add values based on site root under site defintion using (new SecurityDisabler()) { /*BEGIN EDIT*/ newSiteDefinition.Editing.BeginEdit(); //setting the hostnames and language newSiteDefinition.Fields["hostName"].Value = txtHostNames.Value; //setting the primary language for the site from the list of languages under system/languages var primaryLanguageItem = database.GetItem(LanguagesItemId).Axes.GetDescendants().FirstOrDefault(x => x.Name.ToLower().Equals(language.ToLower())); if (primaryLanguageItem != null) { ID primaryLanguageId = primaryLanguageItem.ID; newSiteDefinition.Fields["language"].Value = primaryLanguageId.ToString(); } /*END EDIT*/ newSiteDefinition.Editing.EndEdit(); //updating the siteSettings reference var siteSettingsItem = newSiteDefinition.Children.FirstOrDefault(x => x.Name.Equals("siteSettings")); if (siteSettingsItem != null) { siteSettingsItem.Editing.BeginEdit(); var siteSettings = websiteRootItem.Children.FirstOrDefault(x => x.TemplateID.ToString().Equals(SiteSettingsTemplateId)); if (siteSettings != null) { siteSettingsItem.Fields["Value"].Value = siteSettings.ID.ToString(); } siteSettingsItem.Editing.EndEdit(); } } } else { Context.ClientPage.ClientResponse.Alert(Translate.Text("{0} branch was not found.", (object)siteDefinitionBranchTemplateID)); } }
public void Init() { Sitecore.Context.IsUnitTesting = true; Sitecore.Context.SkipSecurityInUnitTests = true; InitContent(); var sampleBranch = _context.CurrentDatabase.Branches[Constants.Paths.Branch]; if (sampleBranch == null) { var branchHome = _context.CurrentDatabase.GetItem("/sitecore/templates/Branches/User Defined"); _branch = TestUtil.CreateContentFromFile("TestResources\\branch.xml", branchHome); } }
protected virtual void ModifyNewFromBranch(Item item, BranchItem branchTemplateItem) { string branchBasePath = branchTemplateItem.InnerItem.Paths.FullPath; // find all rendering data sources on the branch root item that point to an item under the branch template, // and repoint them to the equivalent subitem under the branch instance LayoutHelper.ApplyActionToAllRenderings(item, rendering => RewriteRenderingDatasource(branchBasePath, item, rendering)); foreach (Item childItem in item.Children) { ModifyNewFromBranch(childItem, branchTemplateItem); } }
private void Update(UpdateCommandContext context, EventList oldCalendar, BranchItem branch) { if (!SecurityManager.CanWrite(context.Event.GetTargetItem())) { return; } bool isClearSchedule = !context.UpdateSeries; if (context.Event.IsDateScopeChanged && oldCalendar.ID.ToString() == context.CalendarID && !context.UpdateSeries) { isClearSchedule = true; context.Event.ScheduleID = string.Empty; MoveEvent(context); } if (context.Event != null) { if (context.Schedule != null && !isClearSchedule) { context.Event.ScheduleID = context.Schedule.ID; } if ((context.Schedule != null && context.UpdateSeries && (context.Schedule.IsChanged || context.Event.IsDateScopeChanged)) || (context.UpdateSeries && oldCalendar.ID.ToString() != context.CalendarID)) { this.UpdateAllSeriesTogetherWithSchedule(context, branch); return; } if (oldCalendar.ID.ToString() != context.CalendarID) { UpdateThisOccurrence(context, branch); return; } var events = new List<Event>(); if (context.UpdateSeries && context.Schedule != null) { events.AddRange(context.Schedule.GetTargetEvents()); } else { events.Add(new Event(context.Event.GetTargetItem())); } SyncEvents(context, events); } }
public async Task <IActionResult> Create([Bind("BranchId,ItemId")] BranchItem branchItem) { if (ModelState.IsValid) { _context.Add(branchItem); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["BranchId"] = new SelectList(_context.Set <Branch>(), "Id", "Id", branchItem.BranchId); ViewData["ItemId"] = new SelectList(_context.Item, "Id", "Id", branchItem.ItemId); return(View(branchItem)); }
/// <summary> /// Visits the content of the first or second side of a branch, according to its content type. No more than one of the provided <see cref="Action"/> /// callbacks will be called. /// </summary> /// <param name="childItem"></param> /// <param name="childBranchVisitor"></param> /// <param name="childTabablzControlVisitor"></param> /// <param name="childContentVisitor"></param> /// <returns></returns> public BranchAccessor Visit(BranchItem childItem, Action<BranchAccessor> childBranchVisitor = null, Action<TabablzControl> childTabablzControlVisitor = null, Action<object> childContentVisitor = null) { Func<BranchAccessor> branchGetter; Func<TabablzControl> tabGetter; Func<object> contentGetter; switch (childItem) { case BranchItem.First: branchGetter = () => _firstItemBranchAccessor; tabGetter = () => _firstItemTabablzControl; contentGetter = () => _branch.FirstItem; break; case BranchItem.Second: branchGetter = () => _secondItemBranchAccessor; tabGetter = () => _secondItemTabablzControl; contentGetter = () => _branch.SecondItem; break; default: throw new ArgumentOutOfRangeException("childItem"); } var branchDescription = branchGetter(); if (branchDescription != null) { if (childBranchVisitor != null) childBranchVisitor(branchDescription); return this; } var tabablzControl = tabGetter(); if (tabablzControl != null) { if (childTabablzControlVisitor != null) childTabablzControlVisitor(tabablzControl); return this; } if (childContentVisitor == null) return this; var content = contentGetter(); if (content != null) childContentVisitor(content); return this; }
// GET: BranchItems/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BranchItem branchItem = db.BranchItems.Find(id); if (branchItem == null) { return(HttpNotFound()); } return(View(branchItem)); }
public void UpdateAllSeriesTogetherWithSchedule(UpdateCommandContext context, BranchItem branch) { CalendarActions.DeleteEvent(context.Event.ID, true); string eventEndDate = context.Event.EndDate; if (context.Event.EndDate != context.Schedule.EndDate && context.Event.StartDate == context.Event.EndDate) { context.Event.EndDate = context.Schedule.EndDate; } if (context.Event.StartDate != context.Schedule.StartDate && context.Event.StartDate == eventEndDate) { context.Event.StartDate = context.Schedule.StartDate; } CalendarActions.CreateEvent(context.Event, context.Schedule, context.Options, branch); }
protected virtual void RewriteBranchRenderingDataSources(Item item, BranchItem branchTemplateItem) { string branchBasePath = branchTemplateItem.InnerItem.Paths.FullPath; LayoutHelper.ApplyActionToAllRenderings(item, rendering => { if (string.IsNullOrWhiteSpace(rendering.Datasource)) return RenderingActionResult.None; // note: queries and multiple item datasources are not supported var renderingTargetItem = item.Database.GetItem(rendering.Datasource); if (renderingTargetItem == null) Log.Warn("Error while expanding branch template rendering datasources: data source {0} was not resolvable.".FormatWith(rendering.Datasource), this); // if there was no valid target item OR the target item is not a child of the branch template we skip out if (renderingTargetItem == null || !renderingTargetItem.Paths.FullPath.StartsWith(branchBasePath, StringComparison.OrdinalIgnoreCase)) return RenderingActionResult.None; var relativeRenderingPath = renderingTargetItem.Paths.FullPath.Substring(branchBasePath.Length).TrimStart('/'); relativeRenderingPath = relativeRenderingPath.Substring(relativeRenderingPath.IndexOf('/')); // we need to skip the "/$name" at the root of the branch children var newTargetPath = item.Paths.FullPath + relativeRenderingPath; var newTargetItem = item.Database.GetItem(newTargetPath); // if the target item was a valid under branch item, but the same relative path does not exist under the branch instance // we set the datasource to something invalid to avoid any potential unintentional edits of a shared data source item if (newTargetItem == null) { rendering.Datasource = "INVALID_BRANCH_SUBITEM_ID"; return RenderingActionResult.None; } rendering.Datasource = newTargetItem.ID.ToString(); return RenderingActionResult.None; }); }
public virtual IItem Add(string name, BranchItem branch) { return ItemFactory.BuildItem(_item.Add(name, branch)); }
public void AddEvent(Event ev, BranchItem branch) { CreateEvent(ev, branch); }
public Item CreateEvent(Event ev, BranchItem branch) { CalendarActions.CreateEvent(ev, null, new Options { CalendarID = ID.ToString() }, branch); return ev.GetItem(); }
/// <summary> /// Executes the command in the specified context. /// </summary> /// <param name="context">The context.</param> public override void Execute(CommandContext context) { Assert.ArgumentNotNull(context, "context"); Assert.IsNotNull(Context.ContentDatabase, ContentDatabaseMustNotBeNull); Item item = Context.ContentDatabase.GetItem(context.Parameters[ItemKey]); Item branchInnerItem = Context.ContentDatabase.GetItem(context.Parameters[BranchKey]); Assert.IsNotNull(item, ItemCannotBeFound); Assert.IsNotNull(branchInnerItem, BranchCannotBeFound); BranchItem branchItem = new BranchItem(branchInnerItem); this.BranchLinkUpdater.UpdateItemLinks(branchItem.AddTo(item, context.Parameters[NameKey]), branchItem); }
public void CreateEvent(Event eventItem, Schedule schedule, EventList calendar, BranchItem branch) { if (eventItem == null || calendar == null) { return; } calendar.AddEvent(eventItem, branch); if (schedule != null) { if (schedule.IsNew) { schedule.StartDate = eventItem.StartDate; schedule.EndDate = eventItem.EndDate; CreateSchedule(schedule); } switch (schedule.Recurrence) { case Recurrence.Daily: addDaily(Utilities.StringToDate(schedule.StartDate), eventItem, schedule, calendar); break; case Recurrence.Weekly: addWeekly(Utilities.FirstCalendarDay(Utilities.StringToDate(schedule.StartDate)), eventItem, schedule, calendar); break; case Recurrence.Monthly: addMonthly(Utilities.FirstMonthDay(Utilities.StringToDate(schedule.StartDate)), eventItem, schedule, calendar); break; case Recurrence.Yearly: addYearly(Utilities.FirstMonthDay(Utilities.StringToDate(schedule.StartDate)), eventItem, schedule, calendar); break; default: break; } } }
public void UpdateEvent(Event evnt, Schedule schedule, string calendarID, bool updateSeries, BranchItem branchID) { if (evnt == null) { return; } EventList newCal = EventLists[calendarID]; EventList currentCal = GetCalendar(evnt); if (updateSeries == false) { evnt.ScheduleID = string.Empty; evnt.Save(); PublishUtil.Publishing(evnt.GetTargetItem(), true, false); if (newCal != null && currentCal != null && currentCal.ID != newCal.ID) { currentCal.DeleteEvent(evnt); newCal.AddEvent(evnt, branchID); } return; } if (schedule == null || schedule.IsNew || schedule.IsChanged) { DeleteEvent(evnt.ID, true, true); CreateEvent(evnt, schedule, newCal, branchID); return; } if (newCal != null && currentCal != null) { DeleteEvent(evnt.ID, true, true); evnt.StartDate = schedule.StartDate; evnt.EndDate = schedule.EndDate; CreateEvent(evnt, schedule, newCal, branchID); } if (evnt.IsChanged != true) { return; } ItemLink[] links = Globals.LinkDatabase.GetReferences(schedule.GetTargetItem()); foreach (ItemLink link in links) { evnt.SaveToItem(link.GetSourceItem(), true); } }
public static void CreateEvent(Event ev, Schedule schedule, Options options, BranchItem branch) { Message message = Message.Parse(ev, "event:create"); var calendarContext = new EventCommandContext(ev, schedule, options, branch); Dispatcher.Dispatch(message, calendarContext); }