public ViewResult Create(int id)
        {
            var _user = userRepository.GetUserDetails(id);
            ToDoListCreateViewModel model = new ToDoListCreateViewModel();

            model.UserIDExecutor = _user.UserName;
            return(View("~/Views/ToDoList/Create.cshtml", model));
        }
 public ActionResult SaveListToDo(ToDoListCreateViewModel model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             toDoListRepository.Add(model);
             return(RedirectToAction("index"));
         }
         return(View("index"));
     }
     catch
     {
         return(View("index"));
     }
 }
 public IActionResult Create(ToDoList model)
 {
     if (ModelState.IsValid)
     {
         ToDoListCreateViewModel _newList = new ToDoListCreateViewModel
         {
             ToDoListName            = model.ToDoListName,
             CreatedToDoListDatetime = model.CreatedToDoListDatetime,
             FinalizationDatetime    = model.FinalizationDatetime,
             //ToDoTasks = new List<ToDoTask>(),
             UserIDCreator  = model.UserIDCreator,
             UserIDExecutor = model.UserIDExecutor
         };
         toDoListRepository.Add(_newList);
         return(RedirectToAction("Details", new { id = _newList.ToDoListID }));
         //return View("~/Views/ToDoList/_Layout.cshtml", new { id = _newList.ToDoListID });
     }
     return(View());
 }
Exemple #4
0
 public ToDoListCreateViewModel Add(ToDoListCreateViewModel toDoList)
 {
     context.Add(toDoList);
     context.SaveChanges();
     return(toDoList);
 }