Beispiel #1
0
        public async Task <Result <bool> > ValidateDuplicateAccountNumberAsync(ContaRequest contaRequest)
        {
            if (contaRequest == null)
            {
                return(new Result <bool>(false, HttpStatusCode.BadRequest, Failure.GenerateOneFailure("Object is null.")));
            }

            var account = await _contaService.GetByFilterAsync <ContaResponse>(x => x.Numero == contaRequest.Numero && x.Id != contaRequest.Id);

            if (account.Value?.Count > 0)
            {
                return(new Result <bool>(false, HttpStatusCode.BadRequest, Failure.GenerateOneFailure("The account number is already in use.")));
            }

            return(new Result <bool>(true, HttpStatusCode.OK, null));
        }