diff options
| author | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 15:29:41 +0000 |
|---|---|---|
| committer | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 15:29:41 +0000 |
| commit | 225aa1499e37faf9d38257caabbadc68d78b427e (patch) | |
| tree | 102bb7a40c58595348ae9d3c7076201759fe0720 /Decompiler/Gestor.Application.ViewModels.Drawer.Ajuda/AtendimentosViewModel.cs | |
| parent | 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 (diff) | |
| download | gestor-225aa1499e37faf9d38257caabbadc68d78b427e.tar.gz gestor-225aa1499e37faf9d38257caabbadc68d78b427e.zip | |
decompiler.com
Diffstat (limited to 'Decompiler/Gestor.Application.ViewModels.Drawer.Ajuda/AtendimentosViewModel.cs')
| -rw-r--r-- | Decompiler/Gestor.Application.ViewModels.Drawer.Ajuda/AtendimentosViewModel.cs | 472 |
1 files changed, 472 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.ViewModels.Drawer.Ajuda/AtendimentosViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Drawer.Ajuda/AtendimentosViewModel.cs new file mode 100644 index 0000000..05ffe12 --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels.Drawer.Ajuda/AtendimentosViewModel.cs @@ -0,0 +1,472 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; +using Gestor.Application.Helpers; +using Gestor.Application.Model.Ajuda; +using Gestor.Application.Servicos.Ajuda; +using Gestor.Application.ViewModels.Generic; +using Gestor.Model.API; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; +using Gestor.Model.Helper; +using Gestor.Model.Resources; +using Newtonsoft.Json; + +namespace Gestor.Application.ViewModels.Drawer.Ajuda; + +public class AtendimentosViewModel : BaseViewModel +{ + private readonly AjudaServico _ajudaServico; + + private List<string> _status; + + private string _webbody; + + private Visibility _envioEmailVisibility = (Visibility)2; + + private Visibility _atendimentoVisibility; + + private ObservableCollection<Atendimento> _atendimentos; + + private Atendimento _selectedAtendimento; + + private string _nome; + + private string _ddd; + + private string _telefone; + + private string _email; + + private string _assunto; + + private string _idacesso; + + private string _corpo; + + private string _senhaacesso; + + private ObservableCollection<ArquivoDigital> _arquivosAnexados = new ObservableCollection<ArquivoDigital>(); + + private ArquivoDigital _selectedAnexado = new ArquivoDigital(); + + private string _head; + + public HorarioAtendimento HorarioAtendimento { get; set; } + + public List<string> Status + { + get + { + return _status; + } + set + { + _status = value; + OnPropertyChanged("Status"); + } + } + + public string WebBody + { + get + { + return _webbody?.ToUpper().Trim(); + } + set + { + _webbody = value; + OnPropertyChanged("WebBody"); + } + } + + public Visibility EnvioEmailVisibility + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _envioEmailVisibility; + } + set + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + _envioEmailVisibility = value; + OnPropertyChanged("EnvioEmailVisibility"); + } + } + + public Visibility AtendimentoVisibility + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _atendimentoVisibility; + } + set + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + _atendimentoVisibility = value; + OnPropertyChanged("AtendimentoVisibility"); + } + } + + public ObservableCollection<Atendimento> Atendimentos + { + get + { + return _atendimentos; + } + set + { + _atendimentos = value; + OnPropertyChanged("Atendimentos"); + } + } + + public Atendimento SelectedAtendimento + { + get + { + return _selectedAtendimento; + } + set + { + _selectedAtendimento = value; + WorkOnSelectedAtendimento(value); + OnPropertyChanged("SelectedAtendimento"); + } + } + + public string Nome + { + get + { + return _nome; + } + set + { + _nome = value; + OnPropertyChanged("Nome"); + } + } + + public string Ddd + { + get + { + return _ddd; + } + set + { + _ddd = value; + OnPropertyChanged("Ddd"); + } + } + + public string Telefone + { + get + { + return _telefone; + } + set + { + _telefone = value; + OnPropertyChanged("Telefone"); + } + } + + public string Email + { + get + { + return _email; + } + set + { + _email = value; + OnPropertyChanged("Email"); + } + } + + public string Assunto + { + get + { + return _assunto; + } + set + { + _assunto = value; + OnPropertyChanged("Assunto"); + } + } + + public string IdAcesso + { + get + { + return _idacesso; + } + set + { + _idacesso = value; + OnPropertyChanged("IdAcesso"); + } + } + + public string Corpo + { + get + { + return _corpo; + } + set + { + _corpo = value; + OnPropertyChanged("Corpo"); + } + } + + public string SenhaAcesso + { + get + { + return _senhaacesso; + } + set + { + _senhaacesso = value; + OnPropertyChanged("SenhaAcesso"); + } + } + + public ObservableCollection<ArquivoDigital> ArquivosAnexados + { + get + { + return _arquivosAnexados; + } + set + { + _arquivosAnexados = value; + OnPropertyChanged("ArquivosAnexados"); + } + } + + public ArquivoDigital SelectedAnexado + { + get + { + return _selectedAnexado; + } + set + { + _selectedAnexado = value; + OnPropertyChanged("SelectedAnexado"); + } + } + + public string Head + { + get + { + return _head; + } + set + { + _head = value; + OnPropertyChanged("Head"); + } + } + + private async void HabilitarAtendimento(HorarioAtendimento horario) + { + if (horario == null || horario.Autorizado) + { + AtendimentosViewModel atendimentosViewModel = this; + Usuario usuario = Recursos.Usuario; + atendimentosViewModel.EnableButtons = usuario != null && ((DomainBase)usuario).Id > 0; + return; + } + base.EnableButtons = false; + string text = (horario.InicioDia.HasValue ? (" de " + horario.InicioDia.DiaDaSemana() + " à " + horario.FimDia.DiaDaSemana() + ", das " + horario.InicioHora + "hs às " + horario.FimHora + "hs") : (" das " + horario.InicioHora + "hs às " + horario.FimHora + "hs")); + await ShowMessage("Prezado Cliente," + Environment.NewLine + Environment.NewLine + "Informamos Nosso horário de atendimento e recepção dos mesmos é " + text + "." + Environment.NewLine + "Infelizmente não realizamos agendamento de data/hora de atendimento, por gentileza realize a solicitação dentro do horário comercial que retornaremos a você."); + } + + public AtendimentosViewModel() + { + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + //IL_0013: Unknown result type (might be due to invalid IL or missing references) + //IL_001d: Expected O, but got Unknown + base.EnableButtons = true; + _ajudaServico = new AjudaServico(); + LoadCombo(); + InitialLoad(); + } + + private async void InitialLoad() + { + base.IsEnabled = false; + HorarioAtendimento = await Connection.Get<HorarioAtendimento>("Attendance"); + HabilitarAtendimento(HorarioAtendimento); + base.IsEnabled = true; + } + + private void LoadCombo() + { + Status = new List<string> { "PENDENTES", "FINALIZADOS" }; + } + + public async void WorkOnSelectedStatus(string value) + { + Atendimentos = await _ajudaServico.BuscarAtendimentos(value); + SelecionaAtendimento(); + } + + public void SelecionaAtendimento() + { + if (Atendimentos != null && Atendimentos.Count > 0) + { + SelectedAtendimento = Atendimentos[0]; + } + AtendimentoVisibility = (Visibility)0; + EnvioEmailVisibility = (Visibility)2; + } + + private async void WorkOnSelectedAtendimento(Atendimento value) + { + if (value != null) + { + WebBody = await _ajudaServico.BuscarCorpoAtendimentos(value.IdAtendimento); + } + } + + public async void Anexar() + { + List<ArquivoDigital> list = await AddAttachments(new List<ArquivoDigital>(), new List<ArquivoDigital>()); + if (list != null) + { + list.AddRange(ArquivosAnexados); + ArquivosAnexados = new ObservableCollection<ArquivoDigital>(list); + } + } + + public async Task<List<KeyValuePair<string, string>>> Enviar() + { + try + { + List<KeyValuePair<string, string>> list = Validate(); + if (list.Count > 0) + { + return list; + } + CustomerData val = new CustomerData + { + Corretora = Recursos.Empresa.Nome, + Name = Nome, + AreaCode = Ddd, + Number = Telefone, + Email = Email + }; + string body = $"{Corpo}<hr><p><b>ID Acesso:</b> {IdAcesso}<br><b>Senha Acesso:</b> {SenhaAcesso}</p><p>VERSÃO DO SISTEMA: {ApplicationHelper.Versao}<br />USUÁRIO SISTEMA:{((DomainBase)Recursos.Usuario).Id} {Recursos.Usuario.Login}</p><p>{JsonConvert.SerializeObject((object)val)}</p>"; + CustomerAttendance keyValues = new CustomerAttendance + { + CustomerData = val, + Subject = Assunto, + Body = body, + Attachments = ((IEnumerable<ArquivoDigital>)ArquivosAnexados).Select((Func<ArquivoDigital, Attachment>)((ArquivoDigital x) => new Attachment + { + Description = x.Descricao, + Extension = x.Extensao, + File = x.Arquivo + })).ToList() + }; + bool num = await Connection.Post<CustomerAttendance>("Attendance/Send", keyValues) == null; + LimparComponentes(); + SelecionaAtendimento(); + return num ? null : new List<KeyValuePair<string, string>> + { + new KeyValuePair<string, string>("fail", "") + }; + } + catch (Exception) + { + return new List<KeyValuePair<string, string>> + { + new KeyValuePair<string, string>("fail", "") + }; + } + } + + public void LimparComponentes() + { + Nome = Recursos.Usuario.Nome; + Ddd = Recursos.Usuario.Prefixo; + Telefone = Recursos.Usuario.Telefone; + Email = Recursos.Usuario.Email; + Assunto = null; + IdAcesso = null; + SenhaAcesso = null; + Corpo = string.Empty; + ArquivosAnexados = new ObservableCollection<ArquivoDigital>(); + } + + public List<KeyValuePair<string, string>> Validate() + { + List<KeyValuePair<string, string>> list = ValidationHelper.AddValue(); + if (string.IsNullOrWhiteSpace(Nome)) + { + ValidationHelper.AddValue<string, string>(list, "Nome", Messages.Obrigatorio, true); + } + if (string.IsNullOrWhiteSpace(Ddd)) + { + ValidationHelper.AddValue<string, string>(list, "Ddd", Messages.Obrigatorio, true); + } + else if (!ValidationHelper.ValidacaoPrefixo(Ddd)) + { + ValidationHelper.AddValue<string, string>(list, "Ddd", Messages.Invalido, true); + } + if (string.IsNullOrWhiteSpace(Telefone)) + { + ValidationHelper.AddValue<string, string>(list, "Telefone", Messages.Obrigatorio, true); + } + else if (!ValidationHelper.ValidacaoTelefone(Telefone)) + { + ValidationHelper.AddValue<string, string>(list, "Telefone", Messages.Invalido, true); + } + if (string.IsNullOrWhiteSpace(Email)) + { + ValidationHelper.AddValue<string, string>(list, "Email", Messages.Obrigatorio, true); + } + else if (!ValidationHelper.ValidacaoEmail(Email)) + { + ValidationHelper.AddValue<string, string>(list, "Email", Messages.Invalido, true); + } + if (string.IsNullOrWhiteSpace(Corpo)) + { + ValidationHelper.AddValue<string, string>(list, "Corpo", Messages.Obrigatorio, true); + } + if (string.IsNullOrWhiteSpace(Assunto)) + { + ValidationHelper.AddValue<string, string>(list, "Assunto", Messages.Obrigatorio, true); + } + return list; + } + + public void Delete(ArquivoDigital arquivo) + { + if (SelectedAnexado != null) + { + ArquivoDigital item = ArquivosAnexados.First((ArquivoDigital x) => x.Descricao == arquivo.Descricao); + ArquivosAnexados.Remove(item); + ArquivosAnexados = new ObservableCollection<ArquivoDigital>(ArquivosAnexados); + } + } +} |