コード例 #1
0
        public ActionResult New()
        {
            var user      = User.Identity.GetUserId();
            var ToDoLists = _context.Todos.Where(m => m.User == user);
            var ToDoList  = new ListFormViewModel()
            {
                ToDos = ToDoLists.ToList()
            };


            return(View("New", ToDoList));
        }
コード例 #2
0
        public IActionResult Index()
        {
            var sFromDB = _context.Forms.toArray();

            var viewModels = new List <ListFormViewModel>();

            foreach (var s in sFromDB)
            {
                var viewModel = new ListFormViewModel();
                viewModel.Name     = s.Name;
                viewModel.Searched = s.Searched;

                viewModels.Add(viewModel);
            }
            return(View());
        }
コード例 #3
0
        public ActionResult SaveList(ListFormViewModel model)
        {
            if (_sessionManager.IsActive(model.SessionId))
            {
                var tempList = new ToDoList.DomainModels.ToDoList();
                tempList.ListId   = model.ToDoList.ListId;
                tempList.ListName = model.ToDoList.ListName;
                tempList.UserId   = model.ToDoList.UserId;

                _listManager.AddListToDatabase(tempList);

                return(RedirectToAction("ListIndex", model));
            }
            else
            {
                var viewModel = new ToDoUser();
                return(RedirectToAction("SignInForm", "Auth", viewModel));
            }
        }
コード例 #4
0
        public ActionResult ListForm(BaseViewModel baseViewModel)
        {
            var viewModel = new ListFormViewModel();

            viewModel.SessionId = baseViewModel.SessionId;


            if (_sessionManager.IsActive(viewModel.SessionId))
            {
                viewModel.ToDoList        = new ToDoList.DomainModels.ToDoList();
                viewModel.ToDoList.UserId = _sessionManager.GetSession(viewModel.SessionId).User.ToDoUserId;
                viewModel.User            = _sessionManager.GetSession(viewModel.SessionId).User;
                return(View(viewModel));
            }
            else
            {
                viewModel.User = new ToDoUser();
                return(RedirectToAction("SignInForm", "Auth", viewModel));
            }
        }