/// <summary>
        /// Get action used for visualization of image gallery of entity.
        /// </summary>
        /// <typeparam name="TEntityWithImage">Entity that implements <see cref="IEntityWithImage"/>.</typeparam>
        /// <param name="entityId"></param>
        /// <param name="picturesUrls"></param>
        /// <param name="actionName">Name of the post action used for editing ImageUrl.</param>
        /// <returns></returns>
        protected virtual async Task <IActionResult> GetGalleryActionAsync <TEntityWithImage>(Guid entityId, List <string> picturesUrls, string actionName)
            where TEntityWithImage : class, IEntityWithImage, new()
        {
            SelectableGalleryViewModel model = new SelectableGalleryViewModel();

            model.Pictures        = picturesUrls;
            model.SelectedPicture = await this.Mediator.Send(new GetEntityImageQuery <TEntityWithImage>(entityId));

            model.Controller = this.ControllerName;
            model.Action     = actionName;

            return(this.GalleryView(model));
        }
Exemple #2
0
 public async Task <IActionResult> Gallery(Guid foodId, SelectableGalleryViewModel model)
 {
     return(await PostGalleryActionAsync <Food>(foodId, model));
 }
 /// <summary>
 /// Build action result for gallery view.
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 protected virtual IActionResult GalleryView(SelectableGalleryViewModel model)
 {
     return(this.View("EntityViews/SelectableGallery", model));
 }
        /// <summary>
        /// Post action used for editing ImageUrl of entity.
        /// </summary>
        /// <typeparam name="TEntityWithImage">Entity that implements <see cref="IEntityWithImage"/>.</typeparam>
        /// <param name="entityId"></param>
        /// <param name="model"></param>
        /// <returns></returns>
        protected virtual async Task <IActionResult> PostGalleryActionAsync <TEntityWithImage>(Guid entityId, SelectableGalleryViewModel model)
            where TEntityWithImage : class, IEntityWithImage, new()
        {
            bool applied = await this.Mediator.Send(new ApplyImageCommand <TEntityWithImage>(entityId, model.SelectedPicture));

            this.ShowComputationNotification(applied, "Image has been applied successfully.", "Image has not been applied.");

            return(this.RedirectToAll());
        }