Example #1
0
 public dtoTagSelectItem(liteTagItem tag, Int32 idLanguage, Int32 dLanguage, List <long> idTags)
 {
     Id         = tag.Id;
     Deleted    = tag.Deleted;
     IsDefault  = tag.IsDefault;
     IsSystem   = tag.IsSystem;
     Status     = tag.Status;
     Name       = tag.GetTitle(idLanguage, dLanguage);
     Type       = tag.Type;
     IdModule   = tag.IdModule;
     ModuleCode = tag.ModuleCode;
     IsSelected = idTags != null && idTags.Contains(tag.Id);
 }
Example #2
0
        public dtoTagItem(liteTagItem tag, Dictionary <Int32, ModuleTags> permissions, Int32 idLanguage, List <Language> languages, Int32 idCurrentUser)
        {
            Id                = tag.Id;
            Deleted           = tag.Deleted;
            CreatedOn         = tag.CreatedOn;
            ModifiedOn        = tag.ModifiedOn;
            IsDefault         = tag.IsDefault;
            IsSystem          = tag.IsSystem;
            Status            = tag.Status;
            IdDisplayLanguage = idLanguage;
            Translation       = tag.GetTranslation(idLanguage);
            Translations      = tag.Translations.Where(t => t.Deleted == BaseStatusDeleted.None && t.Translation != null && !String.IsNullOrEmpty(t.Translation.Title)).Select(t =>
                                                                                                                                                                               new dtoLanguageItem()
            {
                IdLanguage = t.IdLanguage, LanguageCode = t.LanguageCode, IsDefault = languages.Where(l => l.Id == t.IdLanguage && l.isDefault).Any(), LanguageName = (languages.Where(l => l.Id == t.IdLanguage).Any() ? languages.Where(l => l.Id == t.IdLanguage).Select(l => l.Name).FirstOrDefault() : t.LanguageName)
            }).OrderByDescending(l => l.IsMultiLanguage).ThenByDescending(l => l.IsDefault).ThenBy(l => l.LanguageName).ToList();

            CommunityAssignments = tag.CommunityAssignments.Where(c => c.Deleted == BaseStatusDeleted.None).Count();
            Type         = tag.Type;
            IdModule     = tag.IdModule;
            ModuleCode   = tag.ModuleCode;
            IdCreatedBy  = tag.IdCreatedBy;
            IdModifiedBy = tag.IdModifiedBy;
            Permissions  = new dtoPermission();
            Int32 idOrganization = 0;

            if (tag.IsSystem)
            {
                idOrganization = -3;
            }
            else if (tag.Organizations != null && tag.Organizations.Where(t => t.Deleted == BaseStatusDeleted.None && t.IsDefault && permissions.ContainsKey(t.IdOrganization)).Any())
            {
                idOrganization = tag.Organizations.Where(t => t.Deleted == BaseStatusDeleted.None && t.IsDefault && permissions.ContainsKey(t.IdOrganization)).Select(t => t.IdOrganization).FirstOrDefault();
            }

            if (permissions.ContainsKey(idOrganization))
            {
                Permissions.AllowView           = permissions[idOrganization].List || permissions[idOrganization].Administration || permissions[idOrganization].Edit;
                Permissions.AllowAssignTo       = (tag.Deleted == BaseStatusDeleted.None) && (permissions[idOrganization].List || permissions[idOrganization].Administration || permissions[idOrganization].Edit);
                Permissions.AllowDelete         = tag.Deleted == BaseStatusDeleted.Manual && (permissions[idOrganization].Administration || permissions[idOrganization].DeleteOther || (permissions[idOrganization].DeleteMy && idCurrentUser == IdCreatedBy));
                Permissions.AllowVirtualDelete  = tag.Deleted == BaseStatusDeleted.None && (permissions[idOrganization].Administration || permissions[idOrganization].DeleteOther || (permissions[idOrganization].DeleteMy && idCurrentUser == IdCreatedBy));
                Permissions.AllowUnDelete       = tag.Deleted == BaseStatusDeleted.Manual && (permissions[idOrganization].Administration || permissions[idOrganization].DeleteOther || (permissions[idOrganization].DeleteMy && idCurrentUser == IdCreatedBy));
                Permissions.AllowEdit           = tag.Deleted == BaseStatusDeleted.None && (permissions[idOrganization].Administration || permissions[idOrganization].Edit);
                Permissions.AllowSetAvailable   = tag.Deleted == BaseStatusDeleted.None && tag.Status != lm.Comol.Core.Dashboard.Domain.AvailableStatus.Available && (permissions[idOrganization].Administration || permissions[idOrganization].Edit);
                Permissions.AllowSetUnavailable = tag.Deleted == BaseStatusDeleted.None && tag.Status == lm.Comol.Core.Dashboard.Domain.AvailableStatus.Available && (permissions[idOrganization].Administration || permissions[idOrganization].Edit);
            }
        }
Example #3
0
        public virtual liteTagItem BaseClone()
        {
            liteTagItem tag = new liteTagItem();

            tag.IdModule           = IdModule;
            tag.ModuleCode         = ModuleCode;
            tag.Type               = Type;
            tag.IsDefault          = false;
            tag.IsSystem           = false;
            tag.Status             = lm.Comol.Core.Dashboard.Domain.AvailableStatus.Draft;
            tag.DefaultTranslation = (lm.Comol.Core.DomainModel.Languages.TitleDescriptionObjectTranslation)DefaultTranslation.Clone();
            tag.IdCreatedBy        = IdCreatedBy;
            tag.IdModifiedBy       = IdModifiedBy;
            tag.ModifiedOn         = ModifiedOn;
            tag.CreatedOn          = CreatedOn;
            return(tag);
        }
Example #4
0
        public virtual object Clone()
        {
            liteTagItem clone = BaseClone();

            if (Translations != null)
            {
                clone.Translations = Translations.Where(t => t.Deleted == BaseStatusDeleted.None).Select(t => (liteTagTranslation)t.Clone()).ToList();
            }
            if (CommunityAssignments != null)
            {
                clone.CommunityAssignments = CommunityAssignments.Where(c => c.Deleted == BaseStatusDeleted.None).Select(c => (liteCommunityTag)c.Clone()).ToList();
            }
            if (Organizations != null)
            {
                clone.Organizations = Organizations.Where(c => c.Deleted == BaseStatusDeleted.None).Select(c => (liteOrganizationAvailability)c.Clone()).ToList();
            }
            clone.IdTile = IdTile;
            return(clone);
        }