private void MoveNode(NodePositionMovement npm) { CoreRepository.ClearQueryCache("Nodes"); IList rootNodes = CoreRepository.GetRootNodes(ActiveNode.Site); ActiveNode.Move(rootNodes, npm); CoreRepository.FlushSession(); Context.Response.Redirect(Context.Request.RawUrl); }
private void btnDelete_Click(object sender, EventArgs e) { if (ActiveNode.Sections.Count > 0) { ShowError( "Không thể xóa nút khi có các vùng phân hệ trong nó. Hãy xóa hoặc tạm gỡ toàn bộ các vùng này trước."); } else if (ActiveNode.ChildNodes.Count > 0) { ShowError("Không thể xóa nút khi còn các nút con. Hãy xóa hết các nút con trước."); } else { try { CoreRepository.ClearQueryCache("Nodes"); bool hasParentNode = (ActiveNode.ParentNode != null); if (hasParentNode) { ActiveNode.ParentNode.ChildNodes.Remove(ActiveNode); } else { IList rootNodes = CoreRepository.GetRootNodes(ActiveNode.Site); rootNodes.Remove(ActiveNode); } CoreRepository.DeleteNode(ActiveNode); // Reset the position of the 'neighbour' nodes. if (ActiveNode.Level == 0) { ActiveNode.ReOrderNodePositions(CoreRepository.GetRootNodes(ActiveNode.Site), ActiveNode.Position); } else { ActiveNode.ReOrderNodePositions(ActiveNode.ParentNode.ChildNodes, ActiveNode.Position); } CoreRepository.FlushSession(); if (hasParentNode) { Context.Response.Redirect(String.Format("NodeEdit.aspx?NodeId={0}", ActiveNode.ParentNode.Id)); } else { Context.Response.Redirect("Default.aspx"); } } catch (Exception ex) { ShowError(ex.Message); log.Error(String.Format("Có lỗi khi xóa nút: {0}.", ActiveNode.Id), ex); } } }
private void MoveSections() { int sectionId = Int32.Parse(Context.Request.QueryString["SectionId"]); Section section = (Section)CoreRepository.GetObjectById(typeof(Section), sectionId); section.Node = ActiveNode; if (Context.Request.QueryString["Action"] == "MoveUp") { section.MoveUp(); CoreRepository.FlushSession(); // reset sections, so they will be refreshed from the database when required. ActiveNode.ResetSections(); } else if (Context.Request.QueryString["Action"] == "MoveDown") { section.MoveDown(); CoreRepository.FlushSession(); // reset sections, so they will be refreshed from the database when required. ActiveNode.ResetSections(); } // Redirect to the same page without the section movement parameters Context.Response.Redirect(Context.Request.Path + String.Format("?NodeId={0}", ActiveNode.Id)); }