public ActionResult AddPhotos(List <AlbumPhotosModel> model) { if (model != null && model.Any() && ModelState.IsValid) { var albumId = model.FirstOrDefault().AlbumId; var attachments = new List <int>(); foreach (var m in model) { if (m.IsChecked) { attachments.Add(m.PhotoId); } } _service.Attach(attachments, albumId); } else { return(View(model)); } return(RedirectToAction("UserAlbums", "Albums")); }