public void InitView(Boolean add, long idTile, DashboardType dashboardType, Int32 idContainerCommunity) { Person p = CurrentManager.GetPerson(UserContext.CurrentUserID); if (UserContext.isAnonymous || p == null) { View.DisplaySessionTimeout(); } else { Int32 idTileCommunity = (dashboardType == DashboardType.Community) ? idContainerCommunity : 0; ModuleDashboard permissions = ModuleDashboard.CreatePortalmodule(p.TypeID); List <TileType> availableTypes = null; dtoEditTile tile = null; View.IdTile = idTile; if (add) { availableTypes = Service.GetTileTypesAvailable(dashboardType); tile = new dtoEditTile(); tile.Status = AvailableStatus.Draft; tile.Type = availableTypes.FirstOrDefault(); } else { if (View.PreloadFromAdd) { View.DisplayTileAdded(); } tile = Service.GetEditTile(idTile); idTileCommunity = (tile == null) ? ((dashboardType == DashboardType.Community) ? idContainerCommunity : 0) : tile.IdCommunity; } View.IdTileCommunity = idTileCommunity; if (dashboardType == DashboardType.Community) { View.IdContainerCommunity = idContainerCommunity; if (idTileCommunity < 0) { idTileCommunity = UserContext.CurrentCommunityID; } if (idTileCommunity > 0 && (!permissions.Administration && !permissions.ManageTiles)) { permissions = Service.GetPermission(idTileCommunity); } } else { idContainerCommunity = 0; View.IdContainerCommunity = 0; } if ((tile == null && (idTile > 0 || !add)) || (tile != null && tile.Deleted != BaseStatusDeleted.None && tile.Deleted != BaseStatusDeleted.Manual)) { View.DisplayUnknownTile(); if (!permissions.ManageTiles) { View.DisplayNoPermission(idContainerCommunity, CurrentIdModule); } else { View.SetBackUrl(RootObject.TileList(dashboardType, false, idContainerCommunity, idTile, View.PreloadIdDashboard, View.PreloadStep)); } } else { if (permissions.ManageTiles) { if (tile != null && tile.Id > 0) { View.AllowVirtualUndelete = (tile.Deleted == BaseStatusDeleted.Manual); View.AllowVirtualDelete = (tile.Deleted == BaseStatusDeleted.None); View.AllowDisable = (tile.Deleted == BaseStatusDeleted.None && tile.Status == AvailableStatus.Available); View.AllowEnable = (tile.Deleted == BaseStatusDeleted.None && tile.Status != AvailableStatus.Available); View.SendUserAction(idContainerCommunity, Service.ServiceModuleID(), tile.Id, ModuleDashboard.ActionType.TileStartEditing); } else { View.SendUserAction(idContainerCommunity, Service.ServiceModuleID(), ModuleDashboard.ActionType.TileStartAdding); } View.AllowSave = (tile.Deleted == BaseStatusDeleted.None); View.SetBackUrl(RootObject.TileList(dashboardType, false, idContainerCommunity, idTile, View.PreloadIdDashboard, View.PreloadStep)); switch (tile.Type) { case TileType.CommunityTag: View.InitalizeEditor(tile, idTile, idContainerCommunity, idTileCommunity, ServiceTags.GetTagTranslation(tile.IdTags.FirstOrDefault(), UserContext.Language.Id).Title); break; case TileType.CombinedTags: Language dLanguage = CurrentManager.GetDefaultLanguage(); List <lm.Comol.Core.Tag.Domain.liteTagItem> items = ServiceTags.CacheGetTags(Tag.Domain.TagType.Community, true).Where(t => t.Status == lm.Comol.Core.Dashboard.Domain.AvailableStatus.Available || tile.IdTags.Contains(t.Id)).ToList(); List <lm.Comol.Core.DomainModel.TranslatedItem <long> > tags = items.Select(t => new lm.Comol.Core.DomainModel.TranslatedItem <long>() { Id = t.Id, Translation = t.GetTitle(UserContext.Language.Id, dLanguage.Id) }).ToList(); View.InitalizeEditor(tile, idTile, idContainerCommunity, idTileCommunity, tags, availableTypes); break; case TileType.CommunityType: View.InitalizeEditor(tile, idTile, idContainerCommunity, idTileCommunity, Service.GetCommunityTypeName(tile.IdCommunityTypes.FirstOrDefault(), UserContext.Language.Id)); break; default: View.InitalizeEditor(tile, idTile, idContainerCommunity, idTileCommunity, availableTypes); break; } } else { View.DisplayNoPermission(idContainerCommunity, CurrentIdModule); } } } }
public void InitView(long idTile, DashboardType dashboardType, Int32 idContainerCommunity) { Person p = CurrentManager.GetPerson(UserContext.CurrentUserID); if (UserContext.isAnonymous || p == null) { View.DisplaySessionTimeout(); } else { Int32 idTileCommunity = (dashboardType == DashboardType.Community) ? idContainerCommunity : 0; ModuleDashboard permissions = ModuleDashboard.CreatePortalmodule(p.TypeID); dtoEditTile tile = Service.GetEditTile(idTile); idTileCommunity = (tile == null) ? ((dashboardType == DashboardType.Community) ? idContainerCommunity : 0) : tile.IdCommunity; if (dashboardType == DashboardType.Community) { View.IdContainerCommunity = idContainerCommunity; if (idTileCommunity < 0) { idTileCommunity = UserContext.CurrentCommunityID; } if (idTileCommunity > 0 && (!permissions.Administration && !permissions.ManageTiles)) { permissions = Service.GetPermission(idTileCommunity); } } else { idContainerCommunity = 0; View.IdContainerCommunity = 0; } if ((tile == null && (idTile > 0)) || (tile != null && tile.Deleted != BaseStatusDeleted.None && tile.Deleted != BaseStatusDeleted.Manual)) { View.DisplayUnknownTile(); } if (permissions.ManageTiles) { View.SendUserAction(idContainerCommunity, Service.ServiceModuleID(), ModuleDashboard.ActionType.TileView); View.SetBackUrl(RootObject.TileList(dashboardType, false, idContainerCommunity, idTile, View.PreloadIdDashboard, View.PreloadStep)); List <lm.Comol.Core.DomainModel.Languages.dtoLanguageItem> languages = CurrentManager.GetAllLanguages().OrderByDescending(l => l.isDefault).ThenBy(l => l.Name).Select(l => new lm.Comol.Core.DomainModel.Languages.dtoLanguageItem() { IdLanguage = l.Id, LanguageCode = l.Code, LanguageName = l.Name }).ToList(); languages.Insert(0, new lm.Comol.Core.DomainModel.Languages.dtoLanguageItem() { IdLanguage = 0, LanguageCode = View.GetDefaultLanguageCode(), LanguageName = View.GetDefaultLanguageName(), IsMultiLanguage = true }); switch (tile.Type) { case TileType.CommunityTag: View.LoadTile(tile, ServiceTags.GetTagTranslation(tile.IdTags.FirstOrDefault(), UserContext.Language.Id).Title, languages, languages.Select(l => new dtoTileFullTranslation(l, tile)).ToList()); break; case TileType.CombinedTags: Language dLanguage = CurrentManager.GetDefaultLanguage(); List <lm.Comol.Core.Tag.Domain.liteTagItem> items = ServiceTags.CacheGetTags(Tag.Domain.TagType.Community, true).Where(t => t.Status == lm.Comol.Core.Dashboard.Domain.AvailableStatus.Available || tile.IdTags.Contains(t.Id)).ToList(); List <lm.Comol.Core.DomainModel.TranslatedItem <long> > tags = items.Select(t => new lm.Comol.Core.DomainModel.TranslatedItem <long>() { Id = t.Id, Translation = t.GetTitle(UserContext.Language.Id, dLanguage.Id) }).ToList(); View.LoadTile(tile, tags, languages, languages.Select(l => new dtoTileFullTranslation(l, tile)).ToList()); break; case TileType.CommunityType: View.LoadTile(tile, Service.GetCommunityTypeName(tile.IdCommunityTypes.FirstOrDefault(), UserContext.Language.Id), languages, languages.Select(l => new dtoTileFullTranslation(l, tile)).ToList()); break; default: View.LoadTile(tile, languages, languages.Select(l => new dtoTileFullTranslation(l, tile)).ToList()); break; } View.SendUserAction(idContainerCommunity, Service.ServiceModuleID(), ModuleDashboard.ActionType.TileView); } else { View.DisplayNoPermission(idContainerCommunity, CurrentIdModule); } } }