Ejemplo n.º 1
0
        private async void Alterar()
        {
            if (View != null && View.Id > 0)
            {
                var alimentoExistente = alimentoService.ObterPorId(View.Id);
                if (alimentoExistente != null)
                {
                    Request.Id          = View.Id;
                    Request.Peso        = View.Peso;
                    Request.Proteina    = View.Proteina;
                    Request.Carboidrato = View.Carboidrato;
                    Request.Gordura     = View.Gordura;
                    Request.Caloria     = View.Caloria;
                    alimentoExistente   = alimentoService.Alterar(Request, "Carlosg");
                    if (alimentoService.Validar)
                    {
                        Progresso = await dialog.ShowProgressAsync(this, "Progresso", "Alterando dados do alimento. Aguarde...");

                        Progresso.SetIndeterminate();
                        await Progresso?.CloseAsync();

                        await this.dialog.ShowMessageAsync(this, "Atenção", "Alimento alterado com sucesso !!!");

                        Limpar();
                    }
                    else
                    {
                        await this.dialog.ShowMessageAsync(this, "Atenção", string.Join("\r\n", alimentoService.Notificacoes.Select(s => s.Mensagem)));

                        alimentoService.LimparNotificacoes();
                    }
                    BuscarAlimentos();
                }
            }
        }