Пример #1
0
 public ActionResult Update(TagViewModel model)
 {
     Account account = _accountService.LoadByEmail(User.Identity.Name);
     Tag tag = _tagService.Load(model.ID, account);
     tag.Title = model.Title;
     return null;
 }
Пример #2
0
 public ActionResult Create(TagViewModel model)
 {
     Account account = _accountService.LoadByEmail(User.Identity.Name);
     Tag tag = new Tag();
     tag.Title = model.Title;
     _tagService.CreateTag(tag, account);
     model = new TagViewModel(tag);
     return Content(JsonUtils.SerializeObject(model));
 }
Пример #3
0
 public TaskViewModel(Task task)
 {
     this.ID = task.ID;
     this.TaskListID = task.TaskList != null ? task.TaskList.ID : 0;
     this.TaskListTitle = task.TaskList != null ? task.TaskList.Title : String.Empty;
     this.TaskListIsInbox = task.TaskList != null ? task.TaskList.TaskListType == TaskListType.Inbox : false;
     this.Title = task.Title;
     this.Important = task.Important;
     this.Due = task.Due;
     this.Done = task.Done;
     this.Note = task.Note;
     this.SortOrder = task.TaskList != null ? task.TaskList.Tasks.IndexOf(task) : 0;
     this.Tags = new List<TagViewModel>();
     foreach (Tag tag in task.Tags) {
         TagViewModel t = new TagViewModel(tag);
         this.Tags.Add(t);
     }
 }
Пример #4
0
        public ActionResult Tag(long id, List<Sheet> sheets)
        {
            // Get account.
            Account account = _accountService.LoadByEmail(User.Identity.Name);
            AccountViewModel accountViewModel = new AccountViewModel(account);
            ViewData["Account"] = JsonUtils.SerializeObject(accountViewModel);

            // Get tag.
            Tag tag = _tagService.Load(id, account);

            // Get tasks.
            IList<Task> tasks = _taskService.AllForTag(tag, account);

            // Create a tag view model.
            TagViewModel tagViewModel = new TagViewModel(tag);

            // Pass tag view model to view.
            ViewData["Tag"] = JsonUtils.SerializeObject(tagViewModel);

            // Pass tasks to view.
            IList<TaskViewModel> taskViewModels = new List<TaskViewModel>();
            foreach (Task task in tasks)
                taskViewModels.Add(new TaskViewModel(task));
            ViewData["Tasks"] = JsonUtils.SerializeObject(taskViewModels);

            // 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(tag.Title, Url.Action("tag", "home", new { id = id }), defaultStack, model.Sheets);
            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 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 tg in _tagService.AllForAccount(account))
                tags.Add(new TagViewModel(tg));
            ViewData["Tags"] = JsonUtils.SerializeObject(tags);

            // Return view.
            return View("Tag", model);

        }