diff options
Diffstat (limited to 'Codemerx/Gestor.Application/ViewModels/Generic/DialogCopiaViewModel.cs')
| -rw-r--r-- | Codemerx/Gestor.Application/ViewModels/Generic/DialogCopiaViewModel.cs | 168 |
1 files changed, 168 insertions, 0 deletions
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<string> _tipoCopia = new List<string>()
+ {
+ "CÓPIA COMUM",
+ "CÓPIA OCULTA"
+ };
+
+ private string _tipo;
+
+ private string _copiarPara;
+
+ private Gestor.Model.Domain.MalaDireta.Copia _copia;
+
+ private string _erro;
+
+ private ObservableCollection<string> _copiasComuns;
+
+ private ObservableCollection<string> _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<string> CopiasComuns
+ {
+ get
+ {
+ return this._copiasComuns;
+ }
+ set
+ {
+ this._copiasComuns = value;
+ base.OnPropertyChanged("CopiasComuns");
+ }
+ }
+
+ public ObservableCollection<string> 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<string> 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<string>();
+ Gestor.Model.Domain.MalaDireta.Copia copium = copia;
+ if (copium == null)
+ {
+ copium = new Gestor.Model.Domain.MalaDireta.Copia();
+ copium.set_CopiaOculta(new List<string>());
+ copium.set_CopiaComum(new List<string>());
+ }
+ this.Copia = copium;
+ this.CopiasComuns = new ObservableCollection<string>(this.Copia.get_CopiaComum());
+ this.CopiasOcultas = new ObservableCollection<string>(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<string>(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<string>(this.Copia.get_CopiaComum());
+ this.CopiasOcultas = new ObservableCollection<string>(this.Copia.get_CopiaOculta());
+ }
+ }
+}
\ No newline at end of file |