// GET: BackOffice/ShowcasePhotoes/Create
        public async Task<ActionResult> Create(int? imageId)
        {
            var photo = new ShowcasePhoto();

            if (imageId != null && await db.Set<Image>()
                .AnyAsync(i =>
                    i.Id == imageId &&
                    i.ImageUrl != null && i.IsVisible && i.Document.Collection.IsVisible &&
                    i.ShowImage))
            {
                photo.ImageId = imageId.Value;
            }

            photo.Translations.Add(new ShowcasePhotoTranslation
            {
                LanguageCode = LanguageDefinitions.DefaultLanguage
            });

            return View(GenerateViewModel(photo));
        }
        public async Task<ActionResult> Create(ShowcasePhoto showcasePhoto)
        {
            var image = db.Set<Image>().FirstOrDefault(i => i.Id == showcasePhoto.ImageId);

            if (!image.IsVisible)
            {
                ModelState.AddModelError("ImageId", ShowcasePhotoStrings.ValidationError_ImageHidden);
            }

            if (ModelState.IsValid)
            {
                db.Add(showcasePhoto);
                await db.SaveChangesAsync();
                return RedirectToAction("Index");
            }

            return View(GenerateViewModel(showcasePhoto));
        }
        private ShowcasePhotoEditViewModel GenerateViewModel(ShowcasePhoto photo)
        {
            var model = new ShowcasePhotoEditViewModel
            {
                ShowcasePhoto = photo
            };

            model.AvailableImages = db.Set<Image>()
                .Where(i =>
                    i.IsVisible &&
                    i.Document.Collection.IsVisible &&
                    i.ImageUrl != null &&
                    i.ShowImage)
                .ToList()
                .Select(i => new TranslatedViewModel<Image, ImageTranslation>(i))
                .Select(i => new SelectListItem
                {
                    Value = i.Entity.Id.ToString(),
                    Text = i.Translation.Title
                });

            return model;
        }
        public async Task<ActionResult> Edit(ShowcasePhoto showcasePhoto)
        {
            if (ModelState.IsValid)
            {
                db.Update(showcasePhoto);

                foreach (var item in showcasePhoto.Translations)
                {
                    db.UpdateTranslation(item);
                }

                await db.SaveChangesAsync();
                return RedirectToAction("Index");
            }
            return View(GenerateViewModel(showcasePhoto));
        }