示例#1
0
        public ActionResult GetToDo(int id)
        {
            var viewModel = new ToDoViewModel();

            ViewBag.ToDoId = id;
            ViewData.Add("selecteToDo", id);
            var toDoService = new WCFService.ToDoService();
            var request     = new GetToDoRq();

            request.Id = id;
            var todoResponse = toDoService.GetToDoById(request);

            ViewBag.ToDoName       = todoResponse.Name;
            viewModel.ToDoTaskList = new List <ToDoTaskViewModel>();
            foreach (var item in todoResponse.ToDoTaskList)
            {
                viewModel.ToDoTaskList.Add(new ToDoTaskViewModel
                {
                    Id             = item.Id,
                    ToDoId         = item.Id,
                    TaskName       = item.TaskName,
                    Completed      = item.Completed,
                    Description    = item.Description,
                    ExpireDateTime = item.ExpireDateTime
                });
            }
            viewModel.Name   = todoResponse.Name;
            viewModel.Id     = id;
            ViewBag.ToDoName = todoResponse.Name;
            LayoutModel layoutModel = new LayoutModel <ToDoViewModel>(viewModel, ViewBag.ToDoName, viewModel.Id);

            return(View(layoutModel));
        }
示例#2
0
        public ActionResult GetToDoPage(int id, string filterText = null)
        {
            var viewModel   = new ToDoViewModel();
            var toDoService = new WCFService.ToDoService();
            var request     = new GetToDoRq();

            if (!string.IsNullOrEmpty(filterText) && filterText.Equals("completedTask"))
            {
                request.CompletedTask = true;
            }
            else if (!string.IsNullOrEmpty(filterText) && filterText.Equals("expiredTask"))
            {
                request.ExpireDate = true;
            }
            request.Id = id;

            var todoResponse = toDoService.GetToDoById(request);

            viewModel.Id           = todoResponse.Id;
            viewModel.Name         = todoResponse.Name;
            viewModel.ToDoTaskList = new List <ToDoTaskViewModel>();
            foreach (var item in todoResponse.ToDoTaskList)
            {
                viewModel.ToDoTaskList.Add(new ToDoTaskViewModel
                {
                    Id             = item.Id,
                    ToDoId         = item.Id,
                    TaskName       = item.TaskName,
                    Completed      = item.Completed,
                    Description    = item.Description,
                    ExpireDateTime = item.ExpireDateTime
                });
            }

            ViewBag.ToDoName = todoResponse.Name;
            ViewBag.ToDoId   = id;
            LayoutModel layoutModel = new LayoutModel <ToDoViewModel>(viewModel, ViewBag.ToDoName, viewModel.Id);

            return(PartialView("_ToDoList", viewModel));
        }