Beispiel #1
0
        public async Task <List <CartonValidationResult> > ValidateCartonsInRequest(RequestValidationModel validation)
        {
            List <SqlParameter> parms = new List <SqlParameter>
            {
                new SqlParameter {
                    ParameterName = RequestValidateStoredProcedure.StoredProcedureParameters[0].ToString(), Value = validation.CustomerCode.AsDbValue()
                },
                new SqlParameter {
                    ParameterName = RequestValidateStoredProcedure.StoredProcedureParameters[1].ToString(), Value = validation.RequestType.AsDbValue()
                },
                new SqlParameter {
                    ParameterName = RequestValidateStoredProcedure.StoredProcedureParameters[2].ToString(), Value = validation.RequestNo.AsDbValue()
                },
                new SqlParameter {
                    ParameterName = RequestValidateStoredProcedure.StoredProcedureParameters[3].ToString(), Value = validation.TransactionType.AsDbValue()
                },
                new SqlParameter
                {
                    ParameterName = RequestValidateStoredProcedure.StoredProcedureParameters[4].ToString(),
                    TypeName      = RequestValidateStoredProcedure.StoredProcedureTypeNames[0].ToString(),
                    SqlDbType     = SqlDbType.Structured,
                    Value         = validation.CartonList.ToList().ToDataTable()
                },
            };
            var result = await _tcContext.Set <CartonValidationResult>().FromSqlRaw(RequestValidateStoredProcedure.Sql, parms.ToArray()).ToListAsync();

            if (result == null)
            {
                throw new ServiceException(new ErrorMessage[]
                {
                    new ErrorMessage()
                    {
                        Code    = string.Empty,
                        Message = $"nothing to validate"
                    }
                });
            }
            return(result);
        }
Beispiel #2
0
 public async Task <ActionResult> ValidateCarton(RequestValidationModel cartonValidationModel)
 {
     return(Ok(await _requestRepository.ValidateCartonsInRequest(cartonValidationModel)));
 }