public void Delete(int entityTypeId, int ownerId, Guid entityGuid, string name, string entityQualifier = null, string entityQualifierValue = null, Guid?categoryGuid = null, bool?includeInactive = null) { SetProxyCreation(true); var personAlias = GetPersonAlias(); if (name.Contains('^')) { name = name.Split('^')[0]; } TaggedItem taggedItem = null; var tagService = new TagService((Rock.Data.RockContext)Service.Context); var tag = tagService.Get(entityTypeId, entityQualifier, entityQualifierValue, ownerId, name, categoryGuid, includeInactive); if (tag != null) { taggedItem = tag.TaggedItems.Where(i => i.EntityGuid == entityGuid).FirstOrDefault(); } if (taggedItem == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } if (!taggedItem.IsAuthorized("Tag", GetPerson())) { throw new HttpResponseException(HttpStatusCode.Unauthorized); } Service.Delete(taggedItem); Service.Context.SaveChanges(); }
public void Delete(int entityTypeId, int ownerId, Guid entityGuid, string name, string entityQualifier = null, string entityQualifierValue = null, Guid?categoryGuid = null, bool?includeInactive = null) { SetProxyCreation(true); // Deserialize the tag properties // This logic needs to sync with C# code in TagList.SerializeTag: // $"{name}^{tagCssClass}^{iconCssClass}^{backgroundColor}"; if (name.Contains('^')) { name = name.Split('^')[0]; } TaggedItem taggedItem = null; var tagService = new TagService((Rock.Data.RockContext)Service.Context); var tag = tagService.Get(entityTypeId, entityQualifier, entityQualifierValue, ownerId, name, categoryGuid, includeInactive); if (tag != null) { taggedItem = tag.TaggedItems.Where(i => i.EntityGuid == entityGuid).FirstOrDefault(); } if (taggedItem == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } if (!taggedItem.IsAuthorized(Rock.Security.Authorization.TAG, GetPerson((Rock.Data.RockContext)Service.Context))) { throw new HttpResponseException(HttpStatusCode.Unauthorized); } Service.Delete(taggedItem); Service.Context.SaveChanges(); }