using Gestor.Model.Domain.Generic; using Gestor.Model.Helper; using Gestor.Model.Resources; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Runtime.CompilerServices; namespace Gestor.Model.Domain.Financeiro { public class Transferencia { public DateTime Data { get; set; } public BancosContas Destino { get; set; } public BancosContas Origem { get; set; } [JsonIgnore] public Func>> ValidationEvent { get { return new Func>>(this.Validate); } } public decimal Valor { get; set; } public Transferencia() { } public List> Validate() { List> keyValuePairs = ValidationHelper.AddValue(); if (this.Origem == null) { keyValuePairs.AddValue("Origem", Messages.Obrigatorio, true); } if (this.Destino == null) { keyValuePairs.AddValue("Destino", Messages.Obrigatorio, true); } if (this.Origem != null && this.Destino != null && this.Origem.Id == this.Destino.Id) { keyValuePairs.AddValue("CONTAS", "A CONTA DE ORIGEM NÃO PODE SER A MESMA QUE A DESTINO.", true); } if (DateTime.Compare(this.Data, new DateTime(1753, 1, 1)) < 0 || DateTime.Compare(this.Data, new DateTime(9999, 12, 31)) > 0) { keyValuePairs.AddValue("Data", string.Format(Messages.DataInvalida, Array.Empty()), true); } if (this.Valor <= decimal.Zero) { keyValuePairs.AddValue("Valor", Messages.Obrigatorio, true); } return keyValuePairs; } } }