Beispiel #1
0
 public ActionResult SaveEdit(UserList list)
 {
     //Pull the list from the db with the currently logged in user
     //This makes sure the person trying to save the list is the owner.
     UserList authenticatedList = db.UserLists.Where(ul => ul.Id == list.Id && ul.UserId == WebSecurity.CurrentUserId).FirstOrDefault();
     if (authenticatedList != null)
     {
         authenticatedList.Name = list.Name;
         authenticatedList.DateUpdated = DateTime.UtcNow;
         db.SaveChanges();
     }
     return RedirectToAction("Lists", "Users");
 }
Beispiel #2
0
 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");
 }
Beispiel #3
0
 public bool AjaxCreate(String listname)
 {
     bool didCreateList = false;
     UserList newList = new UserList();
     newList.Name = listname;
     newList.UserId = WebSecurity.CurrentUserId;
     newList.DateCreated = DateTime.UtcNow;
     db.UserLists.Add(newList);
     try
     {
         db.SaveChanges();
         didCreateList = true;
     }
     catch
     {
         didCreateList = false;
     }
     return didCreateList;
 }