public ActionResult Update(UserToDoListViewModel model) { try { var user = _UserToDoListService.GetUserToDoList(model.ID); if (user != null) { user.Title = model.Title; user.DueDate = model.DueDate; _UserToDoListService.UpdateUserToDoList(user); } return(Json(new { data = "Edit", Success = true }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { data = "Edit", Success = false }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Update(int id) { var user = _UserToDoListService.GetUserToDoList(id); if (user != null) { UserToDoListViewModel model = new UserToDoListViewModel { ID = id, Title = user.Title, DueDate = user.DueDate }; return(View(model)); } else { return(RedirectToAction("List")); } }
public ActionResult Create(UserToDoListViewModel model) { try { var user = System.Web.HttpContext.Current.GetOwinContext().GetUserManager <ApplicationUserManager>().FindById(System.Web.HttpContext.Current.User.Identity.GetUserId()); var UserToDoList = new UserToDoList { Title = model.Title, DueDate = model.DueDate, UserID = user.Id }; _UserToDoListService.AddUserToDoList(UserToDoList); //var idResult = um.Create(user, model.Password); return(Json(new { data = "Add", Success = true }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { data = "Add", Success = false }, JsonRequestBehavior.AllowGet)); } }