public async Task <IActionResult> Reorder(ReorderAlbumGroupViewModel model) { try { List <int> orderedAlbumIdList = model.Items.OrderBy(x => x.PositionIndex).Select(x => x.AlbumId).ToList(); await _albumGroupRepo.SetOrderedAlbumListAsync(model.GroupId, orderedAlbumIdList); this.SetBootstrapPageAlert("Success", "Album group reordered", BootstrapAlertType.success); return(RedirectToAction(nameof(Index))); } catch (Exception e) { _log.LogError(e, "Error reordering album group"); this.SetBootstrapPageAlert("Error", "Error reordering album group", BootstrapAlertType.success); return(RedirectToAction(nameof(Index))); } }
public async Task <IActionResult> Reorder(int id) { ReorderAlbumGroupViewModel model = new ReorderAlbumGroupViewModel(); model.GroupId = id; AlbumGroupDetail group = await _albumGroupRepo.GetAsync(id); AlbumGroupItemPositionListResult itemsResult = await _albumGroupRepo.GetOrderedAlbumListAsync(id); model.GroupName = group.Name; model.Items = itemsResult.Items.Select(x => new ReorderAlbumGroupItemViewModel { AlbumId = x.AlbumId, AlbumTitle = x.AlbumTitle, PositionIndex = x.PositionIndex }).ToList(); return(View(model)); }