private async Task ExecuteSaveCommand()
        {
            IsBusy = true;

            var powers = Powers?.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).Select(p => p.Trim()) ?? new string[0];

            var superhero = new SuperheroUpdateDTO
            {
                Id              = Id,
                Name            = Name,
                AlterEgo        = AlterEgo,
                Occupation      = Occupation,
                CityName        = CityName,
                PortraitUrl     = PortraitUrl,
                BackgroundUrl   = BackgroundUrl,
                FirstAppearance = FirstAppearance,
                Gender          = Gender,
                Powers          = new HashSet <string>(powers)
            };

            try
            {
                var status = await _client.PutAsync($"superheroes/{Id}", superhero);

                if (status != HttpStatusCode.NoContent)
                {
                    await _dialog.DisplayAlertAsync("Error", $"Error from api: {status}", "OK");
                }
                else
                {
                    var superheroDetailsDTO = new SuperheroDetailsDTO
                    {
                        Id              = Id,
                        Name            = Name,
                        AlterEgo        = AlterEgo,
                        Occupation      = Occupation,
                        CityName        = CityName,
                        PortraitUrl     = PortraitUrl,
                        BackgroundUrl   = BackgroundUrl,
                        FirstAppearance = FirstAppearance,
                        Gender          = Gender,
                        Powers          = superhero.Powers
                    };

                    _messaging.Send(this, UpdateSuperhero, superheroDetailsDTO);
                    await _navigation.CancelAsync();
                }
            }
            catch (Exception e)
            {
                await _dialog.DisplayAlertAsync(e);
            }

            IsBusy = false;
        }
        private async Task ExecuteSaveCommand()
        {
            IsBusy = true;

            var powers = Powers?.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).Select(p => p.Trim()) ?? new string[0];

            var superhero = new SuperheroCreateDTO
            {
                Name            = Name,
                AlterEgo        = AlterEgo,
                Occupation      = Occupation,
                CityName        = CityName,
                PortraitUrl     = PortraitUrl,
                BackgroundUrl   = BackgroundUrl,
                FirstAppearance = FirstAppearance,
                Gender          = Gender,
                Powers          = new HashSet <string>(powers)
            };

            try
            {
                var(status, uri) = await _client.PostAsync("superheroes", superhero);

                if (status != HttpStatusCode.Created)
                {
                    await _dialog.DisplayAlertAsync("Error", $"Error from api: {status}", "OK");
                }
                else
                {
                    var id = int.Parse(uri.AbsoluteUri.Substring(uri.AbsoluteUri.LastIndexOf("/") + 1));

                    var superheroListDTO = new SuperheroListDTO
                    {
                        Id          = id,
                        Name        = Name,
                        AlterEgo    = AlterEgo,
                        PortraitUrl = PortraitUrl
                    };

                    _messaging.Send(this, AddSuperhero, superheroListDTO);

                    await _navigation.CancelAsync();
                }
            }
            catch (Exception e)
            {
                await _dialog.DisplayAlertAsync(e);
            }

            IsBusy = false;
        }
        private async Task ExecuteSaveCommand()
        {
            IsBusy = true;

            var powers = Powers?.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).Select(p => p.Trim()) ?? new string[0];

            var superhero = new SuperheroUpdateDTO
            {
                Id              = Id,
                Name            = Name,
                AlterEgo        = AlterEgo,
                Occupation      = Occupation,
                CityName        = CityName,
                PortraitUrl     = PortraitUrl,
                BackgroundUrl   = BackgroundUrl,
                FirstAppearance = FirstAppearance,
                Gender          = Gender,
                Powers          = new HashSet <string>(powers)
            };

            await _client.PutAsync($"superheroes/{Id}", superhero);

            var superheroDetailsDTO = new SuperheroDetailsDTO
            {
                Id              = Id,
                Name            = Name,
                AlterEgo        = AlterEgo,
                Occupation      = Occupation,
                CityName        = CityName,
                PortraitUrl     = PortraitUrl,
                BackgroundUrl   = BackgroundUrl,
                FirstAppearance = FirstAppearance,
                Gender          = Gender,
                Powers          = superhero.Powers
            };

            _messaging.Send(this, UpdateSuperhero, superheroDetailsDTO);
            await _navigation.CancelAsync();

            IsBusy = false;
        }
        private async Task ExecuteSaveCommand()
        {
            IsBusy = true;

            var powers = Powers?.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).Select(p => p.Trim()) ?? new string[0];

            var superhero = new SuperheroCreateDTO
            {
                Name            = Name,
                AlterEgo        = AlterEgo,
                Occupation      = Occupation,
                CityName        = CityName,
                PortraitUrl     = PortraitUrl,
                BackgroundUrl   = BackgroundUrl,
                FirstAppearance = FirstAppearance,
                Gender          = Gender,
                Powers          = new HashSet <string>(powers)
            };

            var uri = await _client.PostAsync("superheroes", superhero);

            var id = int.Parse(uri.AbsoluteUri.Substring(uri.AbsoluteUri.LastIndexOf("/") + 1));

            var superheroListDTO = new SuperheroListDTO
            {
                Id          = id,
                Name        = Name,
                AlterEgo    = AlterEgo,
                PortraitUrl = PortraitUrl
            };

            _messaging.Send(this, AddSuperhero, superheroListDTO);

            await _navigation.CancelAsync();

            IsBusy = false;
        }