Exemple #1
0
        public virtual async Task <bool> DeleteTag(string tag)
        {
            var hash = GetHash(tag);
            await Di.GetInstance <IJsonStorage <Tag> >().Delete(Tag.PartitionKey, hash);

            await _personIndex.RemoveFromPropertyList(string.Empty, $"tags/any(f: f eq '{hash}' )", "Tags", hash);

            await _busIndex.RemoveFromPropertyList(string.Empty, $"tags/any(f: f eq '{hash}' )", "Tags", hash);

            var searches = await Di.GetInstance <IJsonStorage <SearchQuery> >().Get();

            var searchesWithTags = searches.Where(s => s.SelectedFilters.Any(f => f.Value == hash)).ToList();

            if (!searchesWithTags.Any())
            {
                return(true);
            }

            searchesWithTags.ForEach(s => s.SelectedFilters.RemoveAt(s.SelectedFilters.FindIndex(f => f.Value == hash)));
            await Di.GetInstance <IJsonStorage <SearchQuery> >().Put(searchesWithTags);

            var empty = searchesWithTags.Where(s => s.SearchTerm.IsEmpty() && !s.SelectedFilters.Any());

            if (empty.Any())
            {
                await Di.GetInstance <IJsonStorage <SearchQuery> >().Delete(empty);
            }

            return(false);
        }
Exemple #2
0
        public virtual async Task <bool> Off(string commonidentifier, string actionKey, string actionInstanceId, int registerEnvironment)
        {
            var claimDb = Di.GetInstance <ITableStorageDb <SurveilledItem> >();

            var element = await SurveilledItem.Get(actionKey, actionInstanceId, GetTeam(), claimDb);

            if (element == null)
            {
                return(false);
            }

            claimDb.DeleteMany(new [] { element });

            var latestResultDb = Di.GetInstance <IJsonStorage <LatestSurveillanceResult> >();
            var latestResult   = await LatestSurveillanceResult.GetLatestSurveillanceResult(actionKey, actionInstanceId, GetTeam(), latestResultDb);

            if (latestResult != null)
            {
                await latestResultDb.Delete(latestResult);
            }

            var team = GetTeam().Id;
            var anyOtherSurveillanceItems = TriggerAllSurveillanceItems <RegisterPersonModel> .GetAllSurveillanceItems(Di)
                                            .Any(item => !string.IsNullOrEmpty(item.CommonIdentifier) && item.CommonIdentifier == commonidentifier && item.TeamProjectInt == team);

            if (!anyOtherSurveillanceItems)
            {
                await _personIndex.RemoveFromPropertyList(commonidentifier, "Teams", team.ToString());
            }

            return(true);
        }