Пример #1
0
        //3 match action with Redirect
        public static RedirectCrap MatchActionStuffToRedirect(ActionStuff action)
        {
            var exampleRedirectData = SetupExampleData();

            foreach (var redirect in exampleRedirectData)
            {
                if (redirect.Name == action.Name && redirect.Entity == action.Entity)
                {
                    if (String.IsNullOrWhiteSpace(action.Value))
                    {
                        //Geen parameter
                        if (!redirect.Url.Contains("?"))
                        {
                            redirect.action = action;
                            return(redirect);
                        }
                    }
                    else
                    {
                        if (redirect.Url.Contains("?"))
                        {
                            redirect.action = action;
                            redirect.Url   += action.Value;
                            return(redirect);
                        }
                    }
                }
            }

            return(null);
        }
Пример #2
0
        //2 Determine actions
        public static ActionStuff DetermineKeyWords(List <string> cleanedWords)
        {
            var actionKeyWords = new Dictionary <string, string>();

            actionKeyWords.Add("show", "show");
            actionKeyWords.Add("zoek", "show");
            actionKeyWords.Add("search", "show");
            actionKeyWords.Add("toon", "show");
            actionKeyWords.Add("tonen", "show");

            actionKeyWords.Add("wijzig", "edit");
            actionKeyWords.Add("bewerk", "edit");
            actionKeyWords.Add("edit", "edit");

            var action = new ActionStuff();

            foreach (var actionKeyWord in actionKeyWords)
            {
                if (cleanedWords.Contains(actionKeyWord.Key))
                {
                    action.Name = actionKeyWord.Value;
                    cleanedWords.Remove(actionKeyWord.Key);
                    break;
                }
            }

            var entityKeyWords = new Dictionary <string, string>();

            entityKeyWords.Add("profiel", "profile");
            entityKeyWords.Add("profielen", "profile");
            entityKeyWords.Add("profile", "profile");
            entityKeyWords.Add("profiles", "profile");

            entityKeyWords.Add("factuur", "invoice");
            entityKeyWords.Add("facuren", "invoice");
            entityKeyWords.Add("invoice", "invoice");
            entityKeyWords.Add("invoices", "invoice");

            foreach (var entityKeyWord in entityKeyWords)
            {
                if (cleanedWords.Contains(entityKeyWord.Key))
                {
                    action.Entity = entityKeyWord.Value;
                    cleanedWords.Remove(entityKeyWord.Key);
                    break;
                }
            }


            action.Value = String.Join(",", cleanedWords.ToArray());

            return(action);
        }