Example #1
0
        public static QpPluginVersion Read(int id, int pluginId = 0)
        {
            var result = QpPluginVersionRepository.GetById(id, pluginId);

            if (result == null)
            {
                throw new Exception(string.Format(QpPluginStrings.PluginVersionNotFound, id));
            }
            return(result);
        }
Example #2
0
        public static ListResult <QpPluginVersionListItem> List(ListCommand command, int pluginId)
        {
            command.SortExpression = EntityObject.TranslateSortExpression(command.SortExpression);
            var list = QpPluginVersionRepository.List(pluginId, command, out var totalRecords);

            return(new ListResult <QpPluginVersionListItem>
            {
                Data = list.ToList(),
                TotalRecords = totalRecords
            });
        }
Example #3
0
        public static QpPluginVersion GetMergedVersion(int[] ids, int parentId)
        {
            if (ids == null)
            {
                throw new ArgumentNullException(nameof(ids));
            }
            if (ids.Length != 2)
            {
                throw new ArgumentException("Wrong ids length");
            }

            var parent = QpPluginRepository.GetById(parentId);

            if (parent == null)
            {
                throw new Exception(string.Format(QpPluginStrings.PluginNotFound, parentId));
            }

            var(item1, item2) = GetOrderedIds(ids);
            QpPluginVersion version1, version2;

            version1 = QpPluginVersionRepository.GetById(item1, parentId);
            if (version1 == null)
            {
                throw new Exception(string.Format(QpPluginStrings.PluginVersionNotFound, item1, parentId));
            }

            if (item2 == QpPluginVersion.CurrentVersionId)
            {
                version2    = CreateVersionFromPlugin(parent);
                version2.Id = QpPluginVersion.CurrentVersionId;
            }
            else
            {
                version2 = QpPluginVersionRepository.GetById(item2, parentId);
                if (version2 == null)
                {
                    throw new Exception(string.Format(QpPluginStrings.PluginVersionNotFound, item2, parentId));
                }
            }

            version1.MergeToVersion(version2);
            return(version1);
        }