public async Task <IActionResult> Edit(UpsertSpeakerProfile.Command command)
        {
            var userId = User.Identity.GetSubjectId();

            command.Id      = int.Parse(userId);
            command.BioHtml = _transformer.ToHtml(command.BioMarkdown);

            try
            {
                await _mediator.Send(command);
            }
            catch (ValidationException e)
            {
                return(View(new ProfileEditViewModel
                {
                    Errors = e.Errors.ToList(),
                    BioMarkdown = command.Bio,
                    FamilyName = command.FamilyName,
                    GivenName = command.GivenName,
                    Id = command.Id,
                    LinkedIn = command.LinkedIn,
                    Twitter = command.Twitter,
                    Website = command.Website
                }));
            }

            return(RedirectToAction("Index"));
        }
        public async Task <IActionResult> Edit(UpsertSpeakerProfile.Command command, IFormFile file)
        {
            var userId = User.Identity.GetSubjectId();

            command.Id      = int.Parse(userId);
            command.BioHtml = _transformer.ToHtml(command.BioMarkdown);

            var errors = new List <ValidationFailure>();

            try
            {
                await _mediator.Send(command);
            }
            catch (ValidationException e)
            {
                e.Errors.ToList().ForEach(x => errors.Add(x));
            }

            _imageHandler.SaveProfilePicture(file, userId).Errors.ForEach(x => errors.Add(x));

            if (errors.Any())
            {
                return(View(new ProfileEditViewModel
                {
                    Errors = errors,
                    BioMarkdown = command.Bio,
                    FamilyName = command.FamilyName,
                    GivenName = command.GivenName,
                    Id = command.Id,
                    LinkedIn = command.LinkedIn,
                    Twitter = command.Twitter,
                    Website = command.Website
                }));
            }

            return(RedirectToAction("Index"));
        }