public ActionResult Update(TaskListViewModel model)
 {
     Account account = _accountService.LoadByEmail(User.Identity.Name);
     TaskList taskList = _taskListService.Load(model.ID, account);
     taskList.Title = model.Title;
     return null;
 }
示例#2
0
 public AreaViewModel(Area area, IList<TaskList> taskLists, bool includeTasks)
     : this(area)
 {
     foreach (TaskList taskList in taskLists) {
         if (taskList != null) {
             TaskListViewModel t = new TaskListViewModel(taskList, taskList.Tasks);
             this.TaskLists.Add(t);
         }
     }
 }
 public ActionResult Create(TaskListViewModel model)
 {
     Account account = _accountService.LoadByEmail(User.Identity.Name);
     Area area = _areaService.Load(model.AreaID, account);
     TaskList taskList = new TaskList { Title = model.Title };
     area.AddTaskList(taskList);
     _taskListService.CreateTaskList(taskList, account);
     model = new TaskListViewModel(taskList);
     return Content(JsonUtils.SerializeObject(model));
 }
示例#4
0
        public ActionResult Inbox(List<Sheet> sheets)
        {
            // Get account.
            Account account = _accountService.LoadByEmail(User.Identity.Name);
            AccountViewModel accountViewModel = new AccountViewModel(account);
            ViewData["Account"] = JsonUtils.SerializeObject(accountViewModel);

            // Manage sheets.
            Queue<Sheet> defaultStack = new Queue<Sheet>();
            defaultStack.Enqueue(new Sheet() { Title = account.DashboardTitle, Url = Url.Action("index", "home") });
            SheetViewModel model = new SheetViewModel(sheets);
            model.Sheets = Sheet.Stack("Inbox", Url.Action("inbox", "home"), defaultStack, model.Sheets);
            ViewData["Stack"] = JsonUtils.SerializeObject(model.Sheets);

            // Pass inbox to view.
            ViewData["Inbox"] = JsonUtils.SerializeObject(new TaskListViewModel(account.Inbox));

            // Create a task list view model with tasks.
            TaskListViewModel taskListViewModel = new TaskListViewModel(account.Inbox, account.Inbox.Tasks);

            // Pass task list view model to view.
            ViewData["TaskList"] = JsonUtils.SerializeObject(taskListViewModel);

            // Create collection of area view models for the task list menu.
            IList<AreaViewModel> areas = new List<AreaViewModel>();
            foreach (Area area in account.Areas)
                areas.Add(new AreaViewModel(area, area.TaskLists));
            ViewData["Areas"] = JsonUtils.SerializeObject(areas);

            // Create collection of tag view models for the tags menu.
            IList<TagViewModel> tags = new List<TagViewModel>();
            foreach (Tag tag in _tagService.AllForAccount(account))
                tags.Add(new TagViewModel(tag));
            ViewData["Tags"] = JsonUtils.SerializeObject(tags);

            // Return view.
            return View(model);
        }
示例#5
0
        public ActionResult Reorder(long taskListID, long[] taskIDs)
        {
            // Get account and task list.
            Account account = _accountService.LoadByEmail(User.Identity.Name);
            TaskList taskList = _taskListService.Load(taskListID, account);

            // Reorder tasks based on new order or task ids.
            taskList.ReorderTasks(taskIDs);
            
            // Create a task list view model with tasks.
            TaskListViewModel taskListViewModel = new TaskListViewModel(taskList, taskList.Tasks);

            // Return tasks.
            return Content(JsonUtils.SerializeObject(taskListViewModel.Tasks));
        }
        public ActionResult Due(DueListType dueListType, bool singleListView)
        {
            // Get account.
            Account account = _accountService.LoadByEmail(User.Identity.Name);

            // Get due list.
            TaskList dueList = _taskListService.GetDueList(dueListType, singleListView, account);

            // Create a task list view model with tasks.
            TaskListViewModel taskListViewModel = new TaskListViewModel(dueList, dueList.Tasks);

            // Return tasks.
            return Content(JsonUtils.SerializeObject(taskListViewModel));
        }
示例#7
0
        public ActionResult Search(List<Sheet> sheets, string searchFor)
        {
            // Get account.
            Account account = _accountService.LoadByEmail(User.Identity.Name);
            AccountViewModel accountViewModel = new AccountViewModel(account);
            ViewData["Account"] = JsonUtils.SerializeObject(accountViewModel);

            // Create a task list model to hold "important" tasks.
            TaskList taskList = new TaskList();
            taskList.Title = String.Format("Search Results for '{0}'", searchFor);

            // Find matching tasks.
            IList<Task> tasks = _taskService.Find(searchFor, account);
            
            // Create a task list view model with tasks.
            TaskListViewModel taskListViewModel = new TaskListViewModel(taskList, tasks);

            // Pass task list view model to view.
            ViewData["TaskList"] = JsonUtils.SerializeObject(taskListViewModel);
            
            // Pass search text to view.
            ViewData["SearchText"] = searchFor;
            
            // Manage sheets.
            // NOTE: We always use the default stack for the search results page.
            // ALSO: The url needs to include the search query paramater.
            var url = Url.Action("search", "home") + "/?searchfor=" + searchFor;
            Queue<Sheet> defaultStack = new Queue<Sheet>();
            defaultStack.Enqueue(new Sheet() { Title = account.DashboardTitle, Url = Url.Action("index", "home") });
            SheetViewModel model = new SheetViewModel(sheets);
            model.Sheets = Sheet.Stack("Search Results", url, defaultStack);
            ViewData["Stack"] = JsonUtils.SerializeObject(model.Sheets);

            // Pass inbox to view.
            ViewData["Inbox"] = JsonUtils.SerializeObject(new TaskListViewModel(account.Inbox));

            // Create collection of area view models for the task list menu.
            IList<AreaViewModel> areas = new List<AreaViewModel>();
            foreach (Area ar in account.Areas)
                areas.Add(new AreaViewModel(ar, ar.TaskLists));
            ViewData["Areas"] = JsonUtils.SerializeObject(areas);

            // Create collection of tag view models for the tags menu.
            IList<TagViewModel> tags = new List<TagViewModel>();
            foreach (Tag tag in _tagService.AllForAccount(account))
                tags.Add(new TagViewModel(tag));
            ViewData["Tags"] = JsonUtils.SerializeObject(tags);

            // Return view.
            return View(model);
        }