public async Task <IActionResult> Add(CreateAlbumViewModel model)
        {
            AlbumViewModelMapper mapper = new AlbumViewModelMapper();
            PublishStatus        flags  = PublishStatus.PUBLISHED | PublishStatus.UNPUBLISHED;
            var artistNames             = await _artistRepo.ListNamesAsync(flags);

            model.ArtistOptions = artistNames
                                  .Select(x => new SelectListItem
            {
                Text     = x.Name,
                Value    = x.Id.ToString(),
                Selected = x.Id == model.ArtistId
            }).ToList();
            List <CheckBoxListItem> groupOptions = (await _albumGroupRepo.ListAsync())
                                                   .Select(x => new CheckBoxListItem
            {
                Label      = x.Name,
                Value      = x.Key,
                IsSelected = model.Groups.Any(grp => grp.IsSelected && grp.Value == x.Key)
            }).ToList();

            model.Groups = groupOptions;

            if (ModelState.IsValid)
            {
                int?createdImageId = null;
                if (model.CoverImage != null && model.CoverImage.Length > 0)
                {
                    using (MemoryStream ms = new MemoryStream())
                    {
                        await model.CoverImage.CopyToAsync(ms);

                        ImageReferenceDetail imageRef = await _imageRepo.AddAsync(new ImageReferenceDetail
                        {
                            Data     = ms.ToArray(),
                            FileName = model.CoverImage.FileName,
                            MimeType = model.CoverImage.ContentType
                        });

                        if (imageRef != null)
                        {
                            createdImageId = imageRef.Id;
                        }
                    }
                }


                var result = await _albumRepo.AddAsync(mapper.Map(model, createdImageId));

                await _albumGroupRepo.SetGroupsForAlbum(result.Id, model.Groups.Where(g => g.IsSelected).Select(g => g.Value).ToList());

                this.SetBootstrapPageAlert("Success", "Album added", BootstrapAlertType.success);
                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                return(View(model));
            }
        }