Exemple #1
0
 public async Task <bool> ValidateType(Contract Contract)
 {
     if (Contract.ContractTypeId == 0)
     {
         Contract.AddError(nameof(ContractValidator), nameof(Contract.ContractType), ErrorCode.ContractTypeEmpty);
     }
     return(Contract.IsValidated);
 }
Exemple #2
0
 public async Task <bool> ValidateTotalValue(Contract Contract)
 {
     if (Contract.TotalValue == 0)
     {
         Contract.AddError(nameof(ContractValidator), nameof(Contract.TotalValue), ErrorCode.TotalValueEmpty);
     }
     return(Contract.IsValidated);
 }
Exemple #3
0
 public async Task <bool> ValidateCode(Contract Contract)
 {
     if (string.IsNullOrWhiteSpace(Contract.Code))
     {
         Contract.AddError(nameof(ContractValidator), nameof(Contract.Code), ErrorCode.CodeEmpty);
     }
     return(Contract.IsValidated);
 }
Exemple #4
0
 public async Task <bool> ValidateCurrency(Contract Contract)
 {
     if (Contract.CurrencyId == 0)
     {
         Contract.AddError(nameof(ContractValidator), nameof(Contract.Currency), ErrorCode.CurrencyEmpty);
     }
     return(Contract.IsValidated);
 }
Exemple #5
0
 public async Task <bool> ValidateReceiveAddress(Contract Contract)
 {
     if (string.IsNullOrWhiteSpace(Contract.ReceiveAddress))
     {
         Contract.AddError(nameof(ContractValidator), nameof(Contract.ReceiveAddress), ErrorCode.ReceiveAddressError);
     }
     return(Contract.IsValidated);
 }
Exemple #6
0
 public async Task <bool> ValidateAppUser(Contract Contract)
 {
     if (Contract.AppUserId == 0)
     {
         Contract.AddError(nameof(ContractValidator), nameof(Contract.AppUser), ErrorCode.AppUserEmpty);
     }
     return(Contract.IsValidated);
 }
Exemple #7
0
        private async Task <bool> ValidateStartDateAndEndDate(Contract Contract)
        {
            if (Contract.ValidityDate == null || Contract.ValidityDate == default(DateTime))
            {
                Contract.AddError(nameof(ContractValidator), nameof(Contract.ValidityDate), ErrorCode.ValidityDateError);
            }
            if (Contract.ExpirationDate == null || Contract.ExpirationDate == default(DateTime))
            {
                Contract.AddError(nameof(ContractValidator), nameof(Contract.ExpirationDate), ErrorCode.ExpirationDateError);
            }

            if (Contract.ExpirationDate != null)
            {
                if (Contract.ExpirationDate < Contract.ValidityDate)
                {
                    Contract.AddError(nameof(ContractValidator), nameof(Contract.ExpirationDate), ErrorCode.ExpirationDateRangeError);
                }
            }
            return(Contract.IsValidated);
        }
Exemple #8
0
        public async Task <bool> ValidateId(Contract Contract)
        {
            ContractFilter ContractFilter = new ContractFilter
            {
                Skip = 0,
                Take = 10,
                Id   = new IdFilter {
                    Equal = Contract.Id
                },
                Selects = ContractSelect.Id
            };

            int count = await UOW.ContractRepository.Count(ContractFilter);

            if (count == 0)
            {
                Contract.AddError(nameof(ContractValidator), nameof(Contract.Id), ErrorCode.IdNotExisted);
            }
            return(count == 1);
        }