Esempio n. 1
0
 public ActionResult Create(UserItem input)
 {
     input.UserId = WebSecurity.CurrentUserId;
     using (YearnlyEntities context = new YearnlyEntities())
     {
         context.UserItems.Add(input);
         context.SaveChanges();
     }
     return RedirectToAction("index", "items");
 }
Esempio n. 2
0
        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;
        }
Esempio n. 3
0
 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");
 }
Esempio n. 4
0
        public ActionResult Create(UserItem input)
        {
            input.UserId = WebSecurity.CurrentUserId;
            input.DateCreated = DateTime.UtcNow;
            db.UserItems.Add(input);
            db.SaveChanges();

            return RedirectToAction("index", "items");
        }