public void AddEntryEditedEntry(Tag entry, EntryEditEvent editEvent, ArchivedTagVersion archivedVersion) { var user = _ctx.OfType <User>().GetLoggedUser(_permissionContext); var activityEntry = new TagActivityEntry(entry, editEvent, user, archivedVersion); AddActivityfeedEntry(activityEntry); }
public ArchivedTagVersionContract(ArchivedTagVersion archivedVersion) : base(archivedVersion) { ChangedFields = archivedVersion.Diff.ChangedFields; Reason = archivedVersion.CommonEditEvent; }
public ArchivedTagVersion Archive(IDatabaseContext <Tag> ctx, Tag tag, TagDiff diff, EntryEditEvent reason, string notes = "") { var agentLoginData = ctx.CreateAgentLoginData(PermissionContext); var archived = ArchivedTagVersion.Create(tag, diff, agentLoginData, reason, notes); ctx.OfType <ArchivedTagVersion>().Save(archived); return(archived); }
private static void DoIfExists(ArchivedTagVersion version, TagEditableFields field, XmlCache <ArchivedTagContract> xmlCache, Action <ArchivedTagContract> func) { var versionWithField = version.GetLatestVersionWithField(field); if (versionWithField?.Data != null) { var data = xmlCache.Deserialize(versionWithField.Version, versionWithField.Data); func(data); } }
public async Task <Tag> CreateTagAsync(string englishName) { var tag = new Tag(new LocalizedString(englishName, ContentLanguageSelection.English)); await _ctx.SaveAsync(tag); var archived = ArchivedTagVersion.Create(tag, new TagDiff(), _loginData, EntryEditEvent.Created, string.Empty); await _ctx.SaveAsync(archived); var activityEntry = new TagActivityEntry(tag, EntryEditEvent.Created, _loginData.User, archived); await new ActivityEntryQueries(_ctx.OfType <ActivityEntry>(), null).AddActivityfeedEntryAsync(activityEntry); return(tag); }
public ArchivedTagVersionDetailsContract(ArchivedTagVersion archived, ArchivedTagVersion comparedVersion, IUserPermissionContext permissionContext) { ParamIs.NotNull(() => archived); ArchivedVersion = new ArchivedTagVersionContract(archived); ComparedVersion = comparedVersion != null ? new ArchivedTagVersionContract(comparedVersion) : null; ComparedVersionId = comparedVersion != null ? comparedVersion.Id : 0; Tag = new TagContract(archived.Tag, permissionContext.LanguagePreference); Name = Tag.Name; ComparableVersions = archived.Tag.ArchivedVersionsManager .GetPreviousVersions(archived, permissionContext) .Select(a => ArchivedObjectVersionWithFieldsContract.Create(a, a.Diff.ChangedFields.Value, a.CommonEditEvent)) .ToArray(); Versions = ComparedTagsContract.Create(archived, comparedVersion); ComparedVersionId = Versions.SecondId; }
public static ArchivedTagContract GetAllProperties(ArchivedTagVersion version) { var data = new ArchivedTagContract(); var xmlCache = new XmlCache <ArchivedTagContract>(); var thisVersion = version.Data != null?xmlCache.Deserialize(version.Version, version.Data) : new ArchivedTagContract(); data.CategoryName = thisVersion.CategoryName; data.HideFromSuggestions = thisVersion.HideFromSuggestions; data.Id = thisVersion.Id; data.TranslatedName = thisVersion.TranslatedName; DoIfExists(version, TagEditableFields.Description, xmlCache, v => { data.Description = v.Description; data.DescriptionEng = v.DescriptionEng; }); DoIfExists(version, TagEditableFields.Names, xmlCache, v => data.Names = v.Names); DoIfExists(version, TagEditableFields.Parent, xmlCache, v => data.Parent = v.Parent); DoIfExists(version, TagEditableFields.RelatedTags, xmlCache, v => data.RelatedTags = v.RelatedTags); DoIfExists(version, TagEditableFields.WebLinks, xmlCache, v => data.WebLinks = v.WebLinks); return(data); }
protected void AddEntryEditedEntry(IDatabaseContext <ActivityEntry> ctx, Tag entry, EntryEditEvent editEvent, ArchivedTagVersion archivedVersion) { new Queries.ActivityEntryQueries(ctx, PermissionContext).AddEntryEditedEntry(entry, editEvent, archivedVersion); }
public ArchivedTagVersionContract(ArchivedTagVersion archivedVersion) : base(archivedVersion, archivedVersion.Diff.ChangedFields.Value, archivedVersion.CommonEditEvent) { }
public static ComparedTagsContract Create(ArchivedTagVersion firstData, ArchivedTagVersion secondData) { return(new ComparedTagsContract(Create(firstData, secondData, ArchivedTagContract.GetAllProperties, d => d.Id))); }
public ArchivedTagVersionContract(ArchivedTagVersion archivedVersion, IUserIconFactory userIconFactory) : base(archivedVersion, userIconFactory, archivedVersion.Diff.ChangedFields.Value, archivedVersion.CommonEditEvent) { }