Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [HttpPost, ValidateAntiForgeryToken]
- public ActionResult Update(IList<UserContactUpdate> values, UserContactAction value)
- {
- if (values == null)
- {
- throw new ArgumentNullException("values");
- }
- var identifiers = values.Where(x => x.Selected).Select(x => x.Id).ToList();
- var contacts = this.UserContactService.GetAll(new UserContactIdentifiersSpecification(identifiers));
- var privilege = new UserContactPrivilege();
- if (contacts.Any(contact => !privilege.CanUpdate(contact)))
- {
- return NotAuthorized();
- }
- foreach (var contact in contacts)
- {
- if (value == UserContactAction.Delete)
- {
- this.UserContactService.Delete(contact);
- }
- else
- {
- this.UserContactService.Update(contact, value);
- }
- }
- return RedirectToRoute(UsersRoutes.ContactIndex, new { mode = "default" });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement