public object Clone() { dtoUnsubscribeTreeNode item = new dtoUnsubscribeTreeNode(); item.Id = Id; item.IdFather = IdFather; item.IdOrganization = IdOrganization; item.Name = Name; item.isPrimary = isPrimary; item.CommunityStatus = CommunityStatus; item.Nodes = new List <dtoUnsubscribeTreeNode>(); item.Path = Path; item.SubscriptionStatus = SubscriptionStatus; item.AllowUnsubscriptionFromOrganization = AllowUnsubscriptionFromOrganization; item.CommunityAllowUnsubscribe = CommunityAllowUnsubscribe; item.IdRole = IdRole; item.CommunityAllowSubscription = CommunityAllowSubscription; item.MaxUsersWithDefaultRole = MaxUsersWithDefaultRole; item.CommunitySubscriptionEndOn = CommunitySubscriptionEndOn; item.IdCreatedBy = IdCreatedBy; return(item); }
public void UnsubscribeFromCommunity(Int32 idCommunity, String path, RemoveAction action, lm.Comol.Core.BaseModules.CommunityManagement.dtoCommunitiesFilters filters) { if (UserContext.isAnonymous) { View.DisplaySessionTimeout(); } else { lm.Comol.Core.BaseModules.CommunityManagement.dtoUnsubscribeTreeNode node = Service.UnsubscribeInfo(UserContext.CurrentUserID, idCommunity, path); if (node != null) { switch (action) { case RemoveAction.None: break; default: ModuleDashboard.ActionType dAction = ModuleDashboard.ActionType.UnableToUnsubscribe; List <liteSubscriptionInfo> subscriptions = Service.UnsubscribeFromCommunity(UserContext.CurrentUserID, node, action); if (subscriptions == null && !subscriptions.Any()) { switch (action) { case RemoveAction.FromCommunity: dAction = ModuleDashboard.ActionType.UnableToUnsubscribeFromCommunity; View.DisplayUnableToUnsubscribe(node.Name); break; case RemoveAction.FromAllSubCommunities: dAction = ModuleDashboard.ActionType.UnableToUnsubscribeFromCommunities; View.DisplayUnsubscriptionMessage(new List <String>(), node.GetAllNodes().Where(n => n.AllowUnsubscribe()).Select(n => n.Name).ToList()); break; } } else { switch (action) { case RemoveAction.FromCommunity: dAction = ModuleDashboard.ActionType.UnsubscribeFromCommunity; View.DisplayUnsubscribedFrom(node.Name); break; case RemoveAction.FromAllSubCommunities: dAction = ModuleDashboard.ActionType.UnsubscribeFromCommunities; View.DisplayUnsubscriptionMessage(node.GetAllNodes().Where(n => n.AllowUnsubscribe() && subscriptions.Where(s => s.IdCommunity == n.Id && s.IdRole < 1).Any()).Select(n => n.Name).ToList(), node.GetAllNodes().Where(n => n.AllowUnsubscribe() && subscriptions.Where(s => s.IdCommunity == n.Id && s.IdRole > 0).Any()).Select(n => n.Name).ToList() ); break; } } View.SendUserAction(0, CurrentIdModule, idCommunity, dAction); switch (dAction) { case ModuleDashboard.ActionType.UnsubscribeFromCommunity: case ModuleDashboard.ActionType.UnsubscribeFromCommunities: LoadTree(filters, View.AdvancedMode, View.ReferenceIdCommunity, false); break; } break; } } else { String name = CurrentManager.GetCommunityName(idCommunity); if (!String.IsNullOrEmpty(name)) { View.DisplayUnableToUnsubscribe(name); } View.SendUserAction(0, CurrentIdModule, idCommunity, ModuleDashboard.ActionType.UnableToUnsubscribe); } } }
public void UnsubscribeFromCommunity(Int32 idCommunity, String path, lm.Comol.Core.BaseModules.CommunityManagement.dtoCommunitiesFilters filters) { if (UserContext.isAnonymous) { View.DisplaySessionTimeout(); } else { lm.Comol.Core.BaseModules.CommunityManagement.dtoUnsubscribeTreeNode node = Service.UnsubscribeInfo(UserContext.CurrentUserID, idCommunity, path); if (node != null) { ModuleDashboard.ActionType dAction = ModuleDashboard.ActionType.None; List <lm.Comol.Core.BaseModules.CommunityManagement.dtoUnsubscribeTreeNode> nodes = node.GetAllNodes(); if (!nodes.Where(n => n.AllowUnsubscribe()).Any()) { View.DisplayUnableToUnsubscribe(CurrentManager.GetCommunityName(idCommunity)); dAction = ModuleDashboard.ActionType.UnableToUnsubscribeFromCommunity; } else { List <RemoveAction> actions = new List <RemoveAction>(); actions.Add(RemoveAction.None); actions.Add(RemoveAction.FromCommunity); if (nodes.Where(n => n.AllowUnsubscribe()).Count() > 1) { actions.Add(RemoveAction.FromAllSubCommunities); } if (node == null) { View.DisplayUnableToUnsubscribe(CurrentManager.GetCommunityName(idCommunity)); dAction = ModuleDashboard.ActionType.UnableToUnsubscribeFromCommunity; } else if (!node.AllowUnsubscribe()) { View.DisplayUnsubscribeNotAllowed(node.Name); dAction = ModuleDashboard.ActionType.UnsubscribeNotallowed; } else if (node.AllowUnsubscribe() && (!node.CommunityAllowSubscription || node.MaxUsersWithDefaultRole > 0 || (node.CommunitySubscriptionEndOn.HasValue && DateTime.Now.AddDays(30) > node.CommunitySubscriptionEndOn.Value))) { View.DisplayConfirmMessage(idCommunity, path, node, actions, RemoveAction.None, nodes.Where(n => n.AllowUnsubscribe() && n.Id != idCommunity).ToList()); dAction = ModuleDashboard.ActionType.RequireUnsubscribeConfirm; } else { if (nodes.Where(n => n.AllowUnsubscribe()).Count() > 1) { View.DisplayConfirmMessage(idCommunity, path, node, actions, RemoveAction.FromCommunity, nodes.Where(n => n.AllowUnsubscribe() && n.Id != idCommunity).ToList()); dAction = ModuleDashboard.ActionType.RequireUnsubscribeConfirmFromSubCommunities; } else { List <liteSubscriptionInfo> subscriptions = Service.UnsubscribeFromCommunity(UserContext.CurrentUserID, node, RemoveAction.FromCommunity); if (subscriptions != null && subscriptions.Any() && subscriptions.Count == 1 && subscriptions[0].IdRole < 1) { View.DisplayUnsubscribedFrom(node.Name); dAction = ModuleDashboard.ActionType.UnsubscribeFromCommunity; } else { View.DisplayUnableToUnsubscribe(node.Name); dAction = ModuleDashboard.ActionType.UnableToUnsubscribeFromCommunity; } } } } View.SendUserAction(0, CurrentIdModule, idCommunity, dAction); if (dAction == ModuleDashboard.ActionType.UnsubscribeFromCommunity) { LoadTree(filters, View.AdvancedMode, View.ReferenceIdCommunity, false); } } else { String name = CurrentManager.GetCommunityName(idCommunity); if (!String.IsNullOrEmpty(name)) { View.DisplayUnableToUnsubscribe(CurrentManager.GetCommunityName(idCommunity)); } View.SendUserAction(0, CurrentIdModule, idCommunity, ModuleDashboard.ActionType.UnableToUnsubscribe); } } }