Created
September 23, 2022 20:48
-
-
Save vmussak/8cc262fd7b58cafb9c185d07a7e74c4a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace Partidinha.Domain.Entities.Partida | |
{ | |
public class Partida : BaseEntity | |
{ | |
public int Id { get; set; } | |
public int IdSala { get; set; } | |
public DateTime DataInicio { get; set; } | |
public DateTime DataFim { get; set; } | |
public decimal ValorCartela { get; set; } | |
public decimal ValorKuadra { get; set; } | |
public decimal ValorKina { get; set; } | |
public decimal ValorCronoprovas { get; set; } | |
public decimal? ValorAcumulado { get; set; } | |
public int? QuantidadeDezenas { get; set; } | |
public short QuantidadeAvisosInicio { get; set; } | |
public bool Ativo { get; set; } | |
public int IdUsuarioCadastro { get; set; } | |
public DateTime DataCadastro { get; set; } | |
public int IdUsuarioAlteracao { get; set; } | |
public DateTime DataAlteracao{ get; set; } | |
public bool Validar() | |
{ | |
this.VerificarIdSala() | |
.VerificarDataInicio() | |
.VerificarDataFim() | |
.VerificarValorCartela() | |
.VerificarValorKuadra() | |
.VerificarValorKina() | |
.VerificarValorCronoprovas() | |
.VerificarValorAcumulado() | |
.VerificarQuantidadeDezenas(); | |
return this.IsValid; | |
} | |
private Partida VerificarIdSala() | |
{ | |
if(this.IdSala <= 0) | |
{ | |
this.IsValid = false; | |
this.Message = "O atributo 'IdSala' deve ser um valor maior do que 0."; | |
} | |
return this; | |
} | |
private Partida VerificarDataInicio() | |
{ | |
if (this.DataInicio == DateTime.MinValue || this.DataInicio == DateTime.MaxValue) | |
{ | |
this.IsValid = false; | |
this.Message = "A data do início da partida deve ser uma data válida."; | |
} | |
return this; | |
} | |
private Partida VerificarDataFim() | |
{ | |
if (this.DataFim == DateTime.MinValue || this.DataFim == DateTime.MaxValue) | |
{ | |
this.IsValid = false; | |
this.Message = "A data do final da partida deve ser uma data válida."; | |
} | |
if (this.IsValid && this.DataFim <= this.DataInicio) | |
{ | |
this.IsValid = false; | |
this.Message = "A data do fim da partida deve ser maior do que a data do início da partida."; | |
} | |
return this; | |
} | |
private Partida VerificarValorCartela() | |
{ | |
if (this.ValorCartela <= 0) | |
{ | |
this.IsValid = false; | |
this.Message = "O valor da cartela deve ser maior do que 0."; | |
} | |
return this; | |
} | |
private Partida VerificarValorKuadra() | |
{ | |
if (this.ValorKuadra <= 0) | |
{ | |
this.IsValid = false; | |
this.Message = "O valor da Kuadra deve ser maior do que 0."; | |
} | |
return this; | |
} | |
private Partida VerificarValorKina() | |
{ | |
if (this.ValorKina <= 0) | |
{ | |
this.IsValid = false; | |
this.Message = "O valor da Kina deve ser maior do que 0."; | |
} | |
return this; | |
} | |
private Partida VerificarValorCronoprovas() | |
{ | |
if (this.ValorCronoprovas <= 0) | |
{ | |
this.IsValid = false; | |
this.Message = "O valor do Cronoprovas deve ser maior do que 0."; | |
} | |
return this; | |
} | |
private Partida VerificarValorAcumulado() | |
{ | |
if (this.ValorAcumulado.HasValue && this.ValorAcumulado <= 0) | |
{ | |
this.IsValid = false; | |
this.Message = "Caso informado, o valor do Acumulado deve ser maior do que 0."; | |
} | |
return this; | |
} | |
private Partida VerificarQuantidadeDezenas() | |
{ | |
if (this.ValorAcumulado.HasValue && !this.QuantidadeDezenas.HasValue) | |
{ | |
this.IsValid = false; | |
this.Message = "A quantidade de dezenas precisa ser informada quando existe um valor acumulado."; | |
return this; | |
} | |
if(this.ValorAcumulado.HasValue && this.QuantidadeDezenas > 90) | |
{ | |
this.IsValid = false; | |
this.Message = "A quantidade de dezenas precisa ser menor ou igual a 90."; | |
} | |
return this; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment