Example #1
0
        /// <summary>
        /// Method to remove a photo from a post.
        /// </summary>
        /// <param name="postId">the id of the post to remove the image from</param>
        /// <param name="imagePath">filepath to the image</param>
        /// <param name="eventId">the id of the event that the post exists in.</param>
        /// <returns>a Json object of an image path</returns>
        public JsonResult RemovePhoto(int postId, string imagePath, int eventId)
        {
            List <Picture> updatedPhotos = new List <Picture>();

            RemovePhotoCommand command = new RemovePhotoCommand(new Picture(postId, imagePath, eventId));

            commandBus.Execute(command, delegate(List <Picture> result) { updatedPhotos = result; });

            return(Json(updatedPhotos));
        }
Example #2
0
        public async Task <IActionResult> DeletePhoto(string id)
        {
            var photoId    = Guid.Parse(id);
            var identifier = User.GetUserId();

            var command = new RemovePhotoCommand
            {
                PhotoId      = photoId,
                LoggedUserId = identifier
            };

            await _mediator.Send(command);

            return(NoContent());
        }
Example #3
0
        /// <summary>
        /// Handler for the RemovePhotoCommand command
        /// </summary>
        /// <param name="command">the RemovePhoto Command</param>
        public void HandleCommand(RemovePhotoCommand command)
        {
            List <Picture> listPics = postRepository.RemovePicture(command.Picture);

            commandBus.Reply(command.Identity, listPics);
        }