Пример #1
0
        public ActionResult AddCategory(string name)
        {
            ToDoItemsDb db = new ToDoItemsDb(Properties.Settings.Default.ConStr);

            db.AddCategory(name);
            return(Redirect("/"));
        }
Пример #2
0
        public ActionResult SetCompleted(int id)
        {
            ToDoItemsDb db = new ToDoItemsDb(Properties.Settings.Default.ConStr);

            db.SetCompleted(id);
            return(Redirect("/"));
        }
Пример #3
0
        public ActionResult AddTask(ToDoItem item, int categoryId)
        {
            ToDoItemsDb db = new ToDoItemsDb(Properties.Settings.Default.ConStr);

            item.Completed = false;
            db.AddTask(item, categoryId);
            return(Redirect("/"));
        }
Пример #4
0
        public ActionResult NewTask()
        {
            ToDoItemsDb      db = new ToDoItemsDb(Properties.Settings.Default.ConStr);
            NewTaskViewModel vm = new NewTaskViewModel();

            vm.Categories = db.GetCategories();
            return(View(vm));
        }
Пример #5
0
        public ActionResult ViewTask(int id)
        {
            ToDoItemsDb db = new ToDoItemsDb(Properties.Settings.Default.ConStr);
            var         vm = new ViewItemViewModel {
                ToDoItem = db.GetItem(id)
            };

            return(View(vm));
        }
Пример #6
0
        public ActionResult AddTask(string title, string description, int categoryId,
                                    DateTime dueDate)
        {
            ToDoItemsDb db   = new ToDoItemsDb(Properties.Settings.Default.ConStr);
            ToDoItem    item = new ToDoItem();

            item.Title       = title;
            item.Description = description;
            item.DueDate     = dueDate;
            item.Completed   = false;
            db.AddTask(item, categoryId);
            return(Redirect("/"));
        }
Пример #7
0
        public ActionResult Index(int?categoryId)
        {
            ToDoItemsDb            db = new ToDoItemsDb(Properties.Settings.Default.ConStr);
            ToDoItemsListViewModel vm = new ToDoItemsListViewModel();

            if (categoryId == null || categoryId == 0)
            {
                vm.ToDoItems = db.GetAll();
            }
            else
            {
                vm.ToDoItems = db.GetItemsForCategory(categoryId.Value);
            }
            vm.Categories       = db.GetCategories();
            vm.SelectedCategory = categoryId;
            return(View(vm));
        }