From 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 10:38:18 -0300 Subject: chore: location --- .../ViewModels/Generic/DialogCopiaViewModel.cs | 168 +++++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 Codemerx/Gestor.Application/ViewModels/Generic/DialogCopiaViewModel.cs (limited to 'Codemerx/Gestor.Application/ViewModels/Generic/DialogCopiaViewModel.cs') diff --git a/Codemerx/Gestor.Application/ViewModels/Generic/DialogCopiaViewModel.cs b/Codemerx/Gestor.Application/ViewModels/Generic/DialogCopiaViewModel.cs new file mode 100644 index 0000000..3386705 --- /dev/null +++ b/Codemerx/Gestor.Application/ViewModels/Generic/DialogCopiaViewModel.cs @@ -0,0 +1,168 @@ +using Gestor.Model.Domain.MalaDireta; +using Gestor.Model.Helper; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; + +namespace Gestor.Application.ViewModels.Generic +{ + public class DialogCopiaViewModel : BaseViewModel + { + private List _tipoCopia = new List() + { + "CÓPIA COMUM", + "CÓPIA OCULTA" + }; + + private string _tipo; + + private string _copiarPara; + + private Gestor.Model.Domain.MalaDireta.Copia _copia; + + private string _erro; + + private ObservableCollection _copiasComuns; + + private ObservableCollection _copiasOcultas; + + public Gestor.Model.Domain.MalaDireta.Copia Copia + { + get + { + return this._copia; + } + set + { + this._copia = value; + base.OnPropertyChanged("Copia"); + } + } + + public string CopiarPara + { + get + { + return this._copiarPara; + } + set + { + this._copiarPara = value; + base.OnPropertyChanged("CopiarPara"); + } + } + + public ObservableCollection CopiasComuns + { + get + { + return this._copiasComuns; + } + set + { + this._copiasComuns = value; + base.OnPropertyChanged("CopiasComuns"); + } + } + + public ObservableCollection CopiasOcultas + { + get + { + return this._copiasOcultas; + } + set + { + this._copiasOcultas = value; + base.OnPropertyChanged("CopiasOcultas"); + } + } + + public string Erro + { + get + { + return this._erro; + } + set + { + this._erro = value; + base.OnPropertyChanged("Erro"); + } + } + + public string Tipo + { + get + { + return this._tipo; + } + set + { + this._tipo = value; + base.OnPropertyChanged("Tipo"); + } + } + + public List TipoCopia + { + get + { + return this._tipoCopia; + } + set + { + this._tipoCopia = value; + base.OnPropertyChanged("TipoCopia"); + } + } + + public DialogCopiaViewModel(Gestor.Model.Domain.MalaDireta.Copia copia) + { + this.Tipo = this.TipoCopia.First(); + Gestor.Model.Domain.MalaDireta.Copia copium = copia; + if (copium == null) + { + copium = new Gestor.Model.Domain.MalaDireta.Copia(); + copium.set_CopiaOculta(new List()); + copium.set_CopiaComum(new List()); + } + this.Copia = copium; + this.CopiasComuns = new ObservableCollection(this.Copia.get_CopiaComum()); + this.CopiasOcultas = new ObservableCollection(this.Copia.get_CopiaOculta()); + } + + public void AdicionarCopia() + { + if (!ValidationHelper.ValidacaoEmail(this.CopiarPara)) + { + this.Erro = "E-MAIL INVÁLIDO"; + return; + } + if (this.Copia.get_CopiaOculta().Contains(this.CopiarPara)) + { + this.Erro = "E-MAIL JÁ ADICIONADO"; + return; + } + this.Copia.get_CopiaOculta().Add(this.CopiarPara); + this.CopiasOcultas = new ObservableCollection(this.Copia.get_CopiaOculta()); + this.CopiarPara = string.Empty; + this.Erro = "E-MAIL ADICIONADO COM SUCESSO"; + } + + public void ExcluirCopia(string tipo, string copia) + { + if (tipo == "CÓPIA OCULTA") + { + this.Copia.get_CopiaOculta().Remove(copia); + } + else + { + this.Copia.get_CopiaComum().Remove(copia); + } + this.CopiasComuns = new ObservableCollection(this.Copia.get_CopiaComum()); + this.CopiasOcultas = new ObservableCollection(this.Copia.get_CopiaOculta()); + } + } +} \ No newline at end of file -- cgit v1.2.3