public List <TodoItem> GetTodoItems(IDictionary <string, string> keys)
        {
            var name      = string.Empty;
            var id        = string.Empty;
            var todo      = string.Empty;
            var completed = string.Empty;

            if (keys != null && keys.Any())
            {
                if (keys.ContainsKey("name"))
                {
                    name = keys["name"] ?? string.Empty;
                }
                if (keys.ContainsKey("id"))
                {
                    id = keys["id"] ?? string.Empty;
                }
                if (keys.ContainsKey("todo"))
                {
                    todo = keys["todo"] ?? string.Empty;
                }
                if (keys.ContainsKey("completed"))
                {
                    completed = keys["completed"] ?? string.Empty;
                }
            }

            if (string.IsNullOrWhiteSpace(name))
            {
                return(new List <TodoItem>());
            }

            int identifier = 0;

            int.TryParse(id, out identifier);

            int intCompleted = 0;

            int.TryParse(completed, out intCompleted);
            intCompleted = intCompleted == 1 ? 1 : 0;

            var todoItem = new TodoItem(identifier, todo, intCompleted);

            var todoItems = new List <TodoItem>();

            switch (name.ToLower())
            {
            case "add":
                todoItems = GetOrUpdateList(RequestType.Add, todoItem);
                break;

            case "delete":
                todoItems = GetOrUpdateList(RequestType.Delete, todoItem);
                break;

            case "all":
                todoItems = GetOrUpdateList(RequestType.All, todoItem);
                break;

            case "allactive":
                todoItems = GetOrUpdateList(RequestType.AllActive, todoItem);
                break;

            case "allcompleted":
                todoItems = GetOrUpdateList(RequestType.AllCompleted, todoItem);
                break;

            case "clearcompleted":
                todoItems = GetOrUpdateList(RequestType.ClearCompleted, todoItem);
                break;

            case "toggleall":
                todoItems = GetOrUpdateList(RequestType.ToggleAll, todoItem);
                break;
            }

            return(todoItems);
        }
        public void ToggleActive(int id, int completed)
        {
            TodoItem todoItem = new TodoItem(id, string.Empty, completed);

            GetOrUpdateList(RequestType.ToggleItemComplete, todoItem);
        }