Пример #1
0
        public async Task <IActionResult> CheckContract([FromBody] PostWrapper post)
        {
            //Trim & clean special chars here
            var contractId = post.Post?.Trim() ?? string.Empty;

            if (string.IsNullOrEmpty(contractId))
            {
                return(BadRequest());
            }
            using (_context)
            {
                _context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
                //Check if any request with this contract id exists
                var rq = await _context.Request.SingleOrDefaultAsync(r => r.LoanNo == contractId);

                if (rq != null)
                {
                    //Not valid
                    return(Ok(new ResultWrapper()
                    {
                        Message = $"Khách hàng này đã request với ID: {rq.RequestId}", Valid = false
                    }));
                }
                //Get info from indus
                var customerInfo = await _indus.GetCustomerInfo(contractId.Trim());

                //Check if customer meet bussiness' requirement
                if (CustomerValidator.CheckAndClean(customerInfo, contractId, out var mess, out var cleaned))
                {
                    //Valid
                    return(Ok(new ResultWrapper()
                    {
                        Message = mess, Valid = true
                    }));
                }