Пример #1
0
        public ActionResult DeleteTag(string tagIds)
        {
            DeleteTagIdsRequest request = JsonConvert.DeserializeObject <DeleteTagIdsRequest>(tagIds);

            request.AccountId   = this.Identity.ToAccountID();
            request.RequestedBy = this.Identity.ToUserID();
            tagService.DeleteTags(request);
            return(Json(new { success = true, response = "" }, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        public DeleteTagResponse DeleteTags(DeleteTagIdsRequest request)
        {
            Logger.Current.Verbose("Request to delete the Tag.");
            bool isAssociatedWithWorkflow       = tagRepository.isAssociatedWithWorkflows(request.TagID);
            bool isAssociatedWithLeadScoreRules = tagRepository.isAssociatedWithLeadScoreRules(request.TagID);

            if (isAssociatedWithLeadScoreRules && isAssociatedWithWorkflow)
            {
                throw new UnsupportedOperationException("[|The selected Tag(s) is associated with Workflows and Lead Score Rules|]. [|Delete operation cancelled|].");
            }
            else if (isAssociatedWithLeadScoreRules)
            {
                throw new UnsupportedOperationException("[|The selected Tag(s) is associated with lead score|]. [|Delete operation cancelled|].");
            }
            else if (isAssociatedWithWorkflow)
            {
                throw new UnsupportedOperationException("[|The selected Tag(s) is associated with Workflow|]. [|Delete operation cancelled|].");
            }
            IEnumerable <int> contactIds = tagRepository.DeleteTags(request.TagID, request.AccountId);
            int count = 0;

            foreach (var tagid in request.TagID)
            {
                count = count + indexingService.RemoveTag(tagid, request.AccountId);
                Logger.Current.Verbose("Removed the tag " + tagid + " from elastic search.");
            }
            if (contactIds != null && contactIds.Any())
            {
                contactService.ContactIndexing(new ContactIndexingRequest()
                {
                    ContactIds = contactIds.ToList(), Ids = contactIds.ToLookup(o => o, o => { return(true); })
                });
            }

            Logger.Current.Verbose("Total deleted tags:" + request.TagID.Count()
                                   + ". Total deleted tags from elastic search. Response count from elastic search: " + count);
            return(new DeleteTagResponse());
        }