public ActionResult AddToDoInList(UserToDoListVm vm) { try { var userId = User.Identity.GetUserId(); using (UserToDoAppDBEntities et = new UserToDoAppDBEntities()) { var model = new UserToDoList { utd_order = vm.utd_order, utd_title = vm.utd_title, utd_priority = vm.utd_priority, utd_date = vm.utd_date, utd_created_date = System.DateTime.Now, utd_created_by = userId }; et.UserToDoLists.Add(model); et.SaveChanges(); } return Json(new { key = true, message = "Success", }, JsonRequestBehavior.AllowGet); } catch (Exception ex) { return Json(new { key = false, message = ex.Message }, JsonRequestBehavior.AllowGet); } }
public int AddUserToDoList(UserToDoList _UserToDoList) { repository.Add <UserToDoList>(_UserToDoList); repository.UnitOfWork.SaveChanges(); return(_UserToDoList.ID); }
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)); } }
public void UpdateUserToDoList(UserToDoList _UserToDoList) { repository.Update <UserToDoList>(_UserToDoList); repository.UnitOfWork.SaveChanges(); }