public ActionResult Create(UserItem input) { input.UserId = WebSecurity.CurrentUserId; using (YearnlyEntities context = new YearnlyEntities()) { context.UserItems.Add(input); context.SaveChanges(); } return RedirectToAction("index", "items"); }
public ActionResult Create(String listname) { UserList newList = new UserList(); newList.Name = listname; newList.UserId = WebSecurity.CurrentUserId; newList.DateCreated = DateTime.UtcNow; using (YearnlyEntities context = new YearnlyEntities()) { context.UserLists.Add(newList); context.SaveChanges(); } return RedirectToAction("index", "list"); }