Esempio n. 1
0
 public UpdateProfileCommand(GeekProfileModel profile, long profileId) =>
 (this.Profile, this.ProfileId) = (profile, profileId);
        public async Task <ActionResult <GeekProfileResponse> > UpdatePersonalProfile([FromBody] GeekProfileModel model)
        {
            var user = await this.mediator.Send(new GetCurrentUserQuery());

            var userProfile = await this.mediator.Send(new GetProfileByUserQuery(user.Id));

            var command = new UpdateProfileCommand(model, userProfile.Id);
            var result  = await this.mediator.Send(command);

            if (result.IsFailed)
            {
                return(this.UnprocessableEntity(result));
            }

            var query   = new GetProfileByIdQuery(result.Value);
            var profile = await this.mediator.Send(query);

            return(this.Ok(profile));
        }