Exemplo n.º 1
0
 /// <summary>
 /// Converts the "Type" property of ImplementationGuidePermission to the PermissionTypes enum used by the PermissionManagement model
 /// </summary>
 public static Trifolia.Web.Models.PermissionManagement.PermissionTypes MemberType(this ImplementationGuidePermission igp)
 {
     return(ConvertType(igp.Type));
 }
Exemplo n.º 2
0
        /// <summary>
        /// Returns a single Id based on the type of the permission.
        /// </summary>
        /// <returns>Returns OrganizationId when type is "EntireOrganization", GroupId when type is "Group" and "UserId" when type is "User"</returns>
        public static int PrimaryId(this ImplementationGuidePermission igp)
        {
            int?id = ConvertId(igp.MemberType(), igp.GroupId, igp.UserId);

            return(id != null ? id.Value : -1);
        }
Exemplo n.º 3
0
        public ActionResult NewVersion(int implementationGuideId)
        {
            if (!CheckPoint.Instance.GrantEditImplementationGuide(implementationGuideId))
            {
                throw new AuthorizationException("You do not have permissions to edit this implementation guide!");
            }

            if (this.tdb.ImplementationGuides.Count(y => y.PreviousVersionImplementationGuideId == implementationGuideId) > 0)
            {
                throw new Exception("This implementation guide already has a new version.");
            }

            ImplementationGuide ig = this.tdb.ImplementationGuides.Single(y => y.Id == implementationGuideId);

            if (!ig.IsPublished())
            {
                throw new Exception("Cannot version an implementation guide that has not been published");
            }

            ImplementationGuide newIg = new ImplementationGuide()
            {
                Name = ig.Name,
                ImplementationGuideType = ig.ImplementationGuideType,
                Organization            = ig.Organization,
                PreviousVersionImplementationGuideId = ig.Id,
                PublishStatus     = PublishStatus.GetDraftStatus(this.tdb),
                Version           = ig.Version + 1,
                WebReadmeOverview = ig.WebReadmeOverview,
                WebDescription    = ig.WebDescription
            };

            // Copy permissions
            foreach (var cPermission in ig.Permissions)
            {
                ImplementationGuidePermission newPermission = new ImplementationGuidePermission()
                {
                    GroupId    = cPermission.GroupId,
                    UserId     = cPermission.UserId,
                    Type       = cPermission.Type,
                    Permission = cPermission.Permission
                };
                newIg.Permissions.Add(newPermission);
            }

            // Copy settings
            foreach (var cSetting in ig.Settings)
            {
                ImplementationGuideSetting newSetting = new ImplementationGuideSetting()
                {
                    PropertyName  = cSetting.PropertyName,
                    PropertyValue = cSetting.PropertyValue
                };
                newIg.Settings.Add(newSetting);
            }

            // Copy IG Template Types
            foreach (var cTemplateType in ig.TemplateTypes)
            {
                ImplementationGuideTemplateType newTemplateType = new ImplementationGuideTemplateType()
                {
                    TemplateTypeId = cTemplateType.TemplateTypeId,
                    Name           = cTemplateType.Name,
                    DetailsText    = cTemplateType.DetailsText
                };
                newIg.TemplateTypes.Add(newTemplateType);
            }

            // Copy volume 1
            foreach (var cSection in ig.Sections)
            {
                var newSection = new ImplementationGuideSection()
                {
                    Content = cSection.Content,
                    Heading = cSection.Heading,
                    Level   = cSection.Level,
                    Order   = cSection.Order
                };
                newIg.Sections.Add(newSection);
            }

            this.tdb.SaveChanges();

            IGSettingsManager igSettings    = new IGSettingsManager(this.tdb, implementationGuideId);
            IGSettingsManager newIgSettings = new IGSettingsManager(this.tdb, newIg.Id);

            var cardinalityAtLeastOne            = igSettings.GetSetting(IGSettingsManager.SettingProperty.CardinalityAtLeastOne);
            var cardinalityOneToOne              = igSettings.GetSetting(IGSettingsManager.SettingProperty.CardinalityOneToOne);
            var cardinalityZero                  = igSettings.GetSetting(IGSettingsManager.SettingProperty.CardinalityZero);
            var cardinalityZeroOrMore            = igSettings.GetSetting(IGSettingsManager.SettingProperty.CardinalityZeroOrMore);
            var cardinalityZeroToOne             = igSettings.GetSetting(IGSettingsManager.SettingProperty.CardinalityZeroToOne);
            var categories                       = igSettings.GetSetting(IGSettingsManager.SettingProperty.Categories);
            var useConsolidationConstraintFormat = igSettings.GetBoolSetting(IGSettingsManager.SettingProperty.UseConsolidatedConstraintFormat);
            var volume1Html                      = igSettings.GetSetting(IGSettingsManager.SettingProperty.Volume1Html);

            if (!string.IsNullOrEmpty(cardinalityAtLeastOne))
            {
                newIgSettings.SaveSetting(IGSettingsManager.SettingProperty.CardinalityAtLeastOne, cardinalityAtLeastOne);
            }

            if (!string.IsNullOrEmpty(cardinalityOneToOne))
            {
                newIgSettings.SaveSetting(IGSettingsManager.SettingProperty.CardinalityZero, cardinalityZero);
            }

            if (!string.IsNullOrEmpty(cardinalityZeroOrMore))
            {
                newIgSettings.SaveSetting(IGSettingsManager.SettingProperty.CardinalityZeroOrMore, cardinalityZeroOrMore);
            }

            if (!string.IsNullOrEmpty(cardinalityZeroToOne))
            {
                newIgSettings.SaveSetting(IGSettingsManager.SettingProperty.CardinalityZeroToOne, cardinalityZeroToOne);
            }

            if (!string.IsNullOrEmpty(categories))
            {
                newIgSettings.SaveSetting(IGSettingsManager.SettingProperty.Categories, categories);
            }

            if (!string.IsNullOrEmpty(volume1Html))
            {
                newIgSettings.SaveSetting(IGSettingsManager.SettingProperty.Volume1Html, volume1Html);
            }

            newIgSettings.SaveBoolSetting(IGSettingsManager.SettingProperty.UseConsolidatedConstraintFormat, useConsolidationConstraintFormat);

            return(Json(new { ImplementationGuideId = newIg.Id }));
        }