Пример #1
0
 public ActionResult Update(AreaViewModel model)
 {
     Account account = _accountService.LoadByEmail(User.Identity.Name);
     Area area = account.Areas.Single<Area>(x => x.ID == model.ID);
     area.Title = model.Title;
     return null;
 }
Пример #2
0
 public ActionResult Create(AreaViewModel model)
 {
     Account account = _accountService.LoadByEmail(User.Identity.Name);
     Area area = new Area { Title = model.Title };
     account.AddArea(area);
     _areaService.CreateArea(area, account);
     model = new AreaViewModel(area, area.TaskLists);
     return Content(JsonUtils.SerializeObject(model));
 }
Пример #3
0
        public ActionResult Area(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 area.
            Area area = _areaService.Load(id, account);

            // Create an area view model with task lists and tasks.
            AreaViewModel areaViewModel = new AreaViewModel(area, area.TaskLists, true);

            // Pass area view model to view.
            ViewData["Area"] = JsonUtils.SerializeObject(areaViewModel);

            // Check for replace sheet option.
            bool replaceSheet = Request.Params["option"] != null && Request.Params["option"] == "replace";
            if (replaceSheet)
                sheets.RemoveAt(sheets.Count - 1);

            // 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(area.Title, Url.Action("area", "home", new { id = id }), defaultStack, model.Sheets);
            ViewData["Stack"] = JsonUtils.SerializeObject(model.Sheets);

            foreach (Sheet s in model.Sheets) {
                Logger.Debug(s.Title + " : " + s.Url);
            }

            // 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("Area", model);

        }
Пример #4
0
        public ActionResult Due(List<Sheet> sheets)
        {
            // Get account.
            Account account = _accountService.LoadByEmail(User.Identity.Name);
            AccountViewModel accountViewModel = new AccountViewModel(account);
            ViewData["Account"] = JsonUtils.SerializeObject(accountViewModel);

            // Create an area model to hold "due" tasks.
            Area area = new Area();
            area.Title = "Due";

            // Create list of task lists to hold each due list.
            IList<TaskList> dueLists = new List<TaskList>();

            // Overdue.
            TaskList overdueList = _taskListService.GetDueList(DueListType.Overdue, false, account);
            dueLists.Add(overdueList);

            // Today.
            TaskList todayList = _taskListService.GetDueList(DueListType.Today, false, account);
            dueLists.Add(todayList);

            // Tomorrow.
            TaskList tomorrowList = _taskListService.GetDueList(DueListType.Tomorrow, false, account);
            dueLists.Add(tomorrowList);

            // This week.
            TaskList thisWeekList = _taskListService.GetDueList(DueListType.ThisWeek, false, account);
            dueLists.Add(thisWeekList);

            // Next week.
            TaskList nextWeekList = _taskListService.GetDueList(DueListType.NextWeek, false, account);
            dueLists.Add(nextWeekList);

            // Later
            TaskList laterList = _taskListService.GetDueList(DueListType.Later, false, account);
            dueLists.Add(laterList);

            // Create an area view model with task lists and tasks.
            AreaViewModel areaViewModel = new AreaViewModel(area, dueLists, true);

            // Pass area view model to view.
            ViewData["Area"] = JsonUtils.SerializeObject(areaViewModel);

            // 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("Due", Url.Action("due", "home"), 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 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);
        }
Пример #5
0
        public ActionResult All(List<Sheet> sheets)
        {
            // Get account.
            Account account = _accountService.LoadByEmail(User.Identity.Name);
            AccountViewModel accountViewModel = new AccountViewModel(account);
            ViewData["Account"] = JsonUtils.SerializeObject(accountViewModel);

            // Create an area model to hold "all" task lists.
            Area area = new Area();
            area.Title = "All";

            // Create an area view model with task lists and tasks.
            AreaViewModel areaViewModel = new AreaViewModel(area, account.GetTaskLists(true), true);

            // Pass area view model to view.
            ViewData["Area"] = JsonUtils.SerializeObject(areaViewModel);

            // 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(area.Title, Url.Action("all", "home"), 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 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);
        }