Advertisement
Ludwiq

C# controller

Mar 15th, 2015
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.91 KB | None | 0 0
  1. [HttpPost]
  2.         //[ValidateAntiForgeryToken]
  3.         public ActionResult Edit(List<int> objects, int newCollectionID)
  4.         {
  5.             //if (objects == null || newCollectionID == null)
  6.             //{
  7.             //    return new HttpStatusCodeResult(HttpStatusCode.NoContent);
  8.             //}
  9.             var thingsToEdit = db.Words.Where(w => w.OwnerName == User.Identity.Name).ToList().Where(w => oneOfThem(objects, w.ID));
  10.             foreach (var w in thingsToEdit)
  11.             {
  12.                 w.CollectionID = newCollectionID;
  13.             }
  14.  
  15.             return new HttpStatusCodeResult(HttpStatusCode.OK);
  16.             //return RedirectToAction("Index");
  17.         }
  18.  
  19. public bool oneOfThem(List<int> objects, int id)
  20.         {
  21.             foreach(var a in objects){
  22.                 if(a == id){
  23.                     return true;
  24.                 }
  25.             }
  26.             return false;
  27.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement