Exemple #1
0
        public static void SetFilters(List <Filter> new_filters, IDialogContext context)
        {
            var user_data = context.PrivateConversationData;

            user_data.SetValue <List <Filter> >(FILTERS_ATR, new_filters);

            if (IsLoggedIn(context))
            {
                User u = GetUser(context);
                ContextController.CleanFilters(u);

                foreach (Filter f in new_filters)
                {
                    ContextController.AddFilter(u, f.FilterName, f.Operator, f.Value);
                }
            }
        }
Exemple #2
0
        public static bool AddFilter(Filter f, IDialogContext context)
        {
            foreach (Filter fl in GetFilters(context))
            {
                if (fl.FilterName.Equals(f.FilterName) && fl.Value.Equals(f.Value))
                {
                    return(false);
                }
            }

            var           user_data     = context.PrivateConversationData;
            List <Filter> filters_state = user_data.GetValue <List <Filter> >(FILTERS_ATR);

            filters_state.Add(f);
            user_data.SetValue <List <Filter> >(FILTERS_ATR, filters_state);

            if (IsLoggedIn(context))
            {
                ContextController.AddFilter(GetUser(context), f.FilterName, f.Operator, f.Value);
            }

            return(true);
        }