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 bool AjaxCreate(UserItem input) { bool didCreateItem = false; input.UserId = WebSecurity.CurrentUserId; input.DateCreated = DateTime.UtcNow; try { db.UserItems.Add(input); db.SaveChanges(); didCreateItem = true; } catch { didCreateItem = false; } return didCreateItem; }
public ActionResult SaveEdit(UserItem input) { UserItem authenticatedItem = db.UserItems.Where(ui => ui.Id == input.Id && ui.UserId == WebSecurity.CurrentUserId).FirstOrDefault(); if (authenticatedItem != null) { authenticatedItem.Title = input.Title; authenticatedItem.Link = input.Link; authenticatedItem.Description = input.Description; authenticatedItem.DateUpdated = DateTime.UtcNow; db.SaveChanges(); } return RedirectToAction("Items", "Users"); }
public ActionResult Create(UserItem input) { input.UserId = WebSecurity.CurrentUserId; input.DateCreated = DateTime.UtcNow; db.UserItems.Add(input); db.SaveChanges(); return RedirectToAction("index", "items"); }