Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.86 KB | None | 0 0
  1.         [HttpPost, ValidateAntiForgeryToken]
  2.         public ActionResult Update(IList<UserContactUpdate> values, UserContactAction value)
  3.         {
  4.             if (values == null)
  5.             {
  6.                 throw new ArgumentNullException("values");
  7.             }
  8.  
  9.             var identifiers = values.Where(x => x.Selected).Select(x => x.Id).ToList();
  10.             var contacts = this.UserContactService.GetAll(new UserContactIdentifiersSpecification(identifiers));
  11.             var privilege = new UserContactPrivilege();
  12.  
  13.             if (contacts.Any(contact => !privilege.CanUpdate(contact)))
  14.             {
  15.                 return NotAuthorized();
  16.             }
  17.  
  18.             foreach (var contact in contacts)
  19.             {
  20.                 if (value == UserContactAction.Delete)
  21.                 {
  22.                     this.UserContactService.Delete(contact);
  23.                 }
  24.                 else
  25.                 {
  26.                     this.UserContactService.Update(contact, value);
  27.                 }
  28.             }
  29.  
  30.             return RedirectToRoute(UsersRoutes.ContactIndex, new { mode = "default" });
  31.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement