private void ValidateRequestCheckFirstAndSecondCondition(CheckInforCollectionDTO checkModel)
 {
     if (checkModel == null)
     {
         throw new UserException(ErrorStatusReturn.REQUEST_NULL);
     }
 }
コード例 #2
0
        public bool ValidatePlateAndPhoneWithIdentity(CheckInforCollectionDTO collectionInfo)
        {
            Car          carPLate      = _carRepository.FirstOrDefault(x => x.Plate == collectionInfo.PLate);
            InfoCustomer inforCustomer = _inforCustomerRepository.FirstOrDefault(x => x.CustomerPhone == collectionInfo.CustomerPhone);

            return(true);
        }
        private async Task <InfoCustomer> GetInfoCustomerWithPhoneNumberIfHave(CheckInforCollectionDTO collectionInfo)
        {
            InfoCustomer inforCustomer = GetInfoCustomerQueryFilterByStatusActive().Where(x => x.CustomerPhone == collectionInfo.CustomerPhone).OrderByDescending(x => x.Id).FirstOrDefault();

            if (inforCustomer == null)
            {
                inforCustomer = await GetInfoCustomerFromPTI(collectionInfo);
            }
            return(inforCustomer);
        }
コード例 #4
0
 public ApiJsonResult ValidatePlateAndPhoneWithIdentity(CheckInforCollectionDTO checkModel)
 {
     try
     {
         ValidateRequestCheckAndInfo(checkModel);
         return(new ApiJsonResult(true, new object()));
     }
     catch (Exception ex)
     {
         return(ProcessException(ex));
     }
 }
        private async Task <InfoCustomer> GetInfoCustomerFromPTI(CheckInforCollectionDTO collectionInfo)
        {
            InfoCustomer infoCustomerFromPTI = new InfoCustomer();

            if (!string.IsNullOrEmpty(collectionInfo.IdentityNumber))
            {
                infoCustomerFromPTI = await CustomerServiceCrossRequest.GetInfoCustomerFromPTIbyPhoneNumberAndIdentityNumber(collectionInfo.IdentityNumber, collectionInfo.CustomerPhone);
            }
            else
            {
                infoCustomerFromPTI = await CustomerServiceCrossRequest.GetInfoCustomerFromPTIbyPhoneNumber(collectionInfo.CustomerPhone);
            }
            return(infoCustomerFromPTI);
        }
        private async Task <ConditionValidateDTO> ValidatePhoneWhenPLateNotFound(CheckInforCollectionDTO collectionInfo)
        {
            InfoCustomer inforCustomer = await GetInfoCustomerWithIdentityAndPhoneNumberIfHave(collectionInfo);

            if (inforCustomer == null)
            {
                return(new ConditionValidateDTO(StatusCondition.ACCEPT_NEW));
            }

            InfoCustomerDTO inforReturn = Mapper.Map <InfoCustomerDTO>(inforCustomer);

            SetStatusForCustomerInforReturn(collectionInfo, inforCustomer, inforReturn);

            return(new ConditionValidateDTO(StatusCondition.ACCEPT_RE_NEW_BRIEF_INFOCUSTOMER, inforReturn));
        }
コード例 #7
0
        private bool IsCustomerAndCarInCurrentTransaction(CheckInforCollectionDTO collectionInfo)
        {
            InfoCustomer infoFound = _inforCustomerRepository.FindAll().
                                     Where(x => x.TransactionCode == collectionInfo.TransactionCode &&
                                           x.IdentityNumber == collectionInfo.IdentityNumber && x.CustomerPhone == collectionInfo.CustomerPhone).OrderByDescending(x => x.Id).FirstOrDefault();
            Car carFound = _carRepository.FindAll().
                           Where(x => x.TransactionCode == collectionInfo.TransactionCode &&
                                 x.Plate == collectionInfo.PLate).OrderByDescending(x => x.Id).FirstOrDefault();

            if (infoFound != null && carFound != null)
            {
                return(true);
            }
            return(false);
        }
 private void SetStatusForCustomerInforReturn(CheckInforCollectionDTO collectionInfo, InfoCustomer inforCustomer, InfoCustomerDTO inforReturn)
 {
     if (inforCustomer.Id > 0)
     {
         inforReturn.IsGetDataFromPTI = false;
         inforReturn.IsGetDataFromIC  = true;
     }
     else
     {
         inforReturn.IsGetDataFromPTI = true;
         inforReturn.IsGetDataFromIC  = false;
     }
     if (string.IsNullOrEmpty(collectionInfo.IdentityNumber))
     {
         inforReturn.IdentityNumber = null;
     }
 }
コード例 #9
0
 public async Task <ApiJsonResult> ValidateFirstAndSecondCondition([FromBody] CheckInforCollectionDTO checkModel)
 {
     try
     {
         ValidateRequestCheckFirstAndSecondCondition(checkModel);
         if (string.IsNullOrEmpty(checkModel.TransactionCode)) // validate first condition when create
         {
             return(new ApiJsonResult(true, await _inforCustomerService.ValidateConditionFirstAndSecondCondition(checkModel)));
         }
         else // validate first condition when update
         {
             return(new ApiJsonResult(true, await _inforCustomerService.ValidateConditionFirstAndSecondConditionWhenUpdate(checkModel)));
         }
     }
     catch (Exception ex)
     {
         return(ProcessException(ex));
     }
 }
コード例 #10
0
        private ConditionValidateDTO ValidateSecondConditionWithPlateAndIdentity(CarDTO carReturn, InfoCustomerDTO inforReturn, CheckInforCollectionDTO collectionInfo, CollectionCarDetailDTO detailInsurance)
        {
            CollectionCar sheetCar = _collectionCarRepository.FindAll().OrderByDescending(x => x.CreatedDate)
                                     .FirstOrDefault(x => x.CollectionSheet.InfoCustomerId == inforReturn.Id);

            if (sheetCar == null)
            {
                return(new ConditionValidateDTO(StatusCondition.ACCEPT_RE_NEW_BRIEF_INFOCUSTOMER_AND_CAR, inforReturn, carReturn, detailInsurance));
            }

            DateTime currentDate = DateTime.Now;

            if ((currentDate.Year - sheetCar.CollectionSheet.TransactionDate.Value.Year) <= 3)
            {
                return(new ConditionValidateDTO(StatusCondition.DENIED));
            }
            else
            {
                if (detailInsurance == null)
                {
                    return(new ConditionValidateDTO(StatusCondition.ACCEPT_RE_NEW_BRIEF_INFOCUSTOMER_AND_CAR, inforReturn, carReturn));
                }

                return(new ConditionValidateDTO(StatusCondition.ACCEPT_RE_NEW_BRIEF_INFOCUSTOMER_AND_CAR, inforReturn, carReturn, detailInsurance));
            }
        }
        private async Task <InfoCustomer> GetInfoCustomerWithIdentityAndPhoneNumberIfHave(CheckInforCollectionDTO collectionInfo)
        {
            InfoCustomer inforCustomer = null;

            if (string.IsNullOrEmpty(collectionInfo.IdentityNumber)) // get lastest info customer and remove identity number, after that respone to client
            {
                inforCustomer = GetInfoCustomerQueryFilterByStatusActive().Where(x => x.CustomerPhone == collectionInfo.CustomerPhone).OrderByDescending(x => x.Id).FirstOrDefault();
            }
            else //get laster info customer by identity and phone number
            {
                inforCustomer = GetInfoCustomerQueryFilterByStatusActive().FirstOrDefault(x => x.CustomerPhone == collectionInfo.CustomerPhone && x.IdentityNumber == collectionInfo.IdentityNumber);
            }

            if (inforCustomer == null)
            {
                inforCustomer = await GetInfoCustomerFromPTI(collectionInfo);
            }

            return(inforCustomer);
        }
        private async Task <ConditionValidateDTO> ValidatePhoneAndIdentityWhenPLateNotFound(CheckInforCollectionDTO collectionInfo)
        {
            InfoCustomer infoCustomerByPhoneNumber = await GetInfoCustomerWithPhoneNumberIfHave(collectionInfo);

            InfoCustomer infoCustomerByIdentityNumber = await GetInfoCustomerWithIdentityNumberIfHave(collectionInfo);

            if (infoCustomerByIdentityNumber != null) // identity high priority
            {
                InfoCustomerDTO inforReturn = Mapper.Map <InfoCustomerDTO>(infoCustomerByIdentityNumber);
                SetStatusForCustomerInforReturn(collectionInfo, infoCustomerByIdentityNumber, inforReturn);
                return(new ConditionValidateDTO(StatusCondition.ACCEPT_RE_NEW_BRIEF_INFOCUSTOMER, inforReturn));
            }

            if (infoCustomerByPhoneNumber != null) // after that is phone number
            {
                InfoCustomerDTO inforReturn = Mapper.Map <InfoCustomerDTO>(infoCustomerByPhoneNumber);
                SetStatusForCustomerInforReturn(collectionInfo, infoCustomerByPhoneNumber, inforReturn);
                return(new ConditionValidateDTO(StatusCondition.ACCEPT_RE_NEW_BRIEF_INFOCUSTOMER, inforReturn));
            }

            return(new ConditionValidateDTO(StatusCondition.ACCEPT_NEW));
        }
        private async Task <ConditionValidateDTO> ValidatePhoneAndIdentityWhenPLateFound(CarDTO carReturn, CheckInforCollectionDTO collectionInfo)
        {
            InfoCustomer infoCustomerByPhoneNumber = await GetInfoCustomerWithPhoneNumberIfHave(collectionInfo);

            InfoCustomer infoCustomerByIdentityNumber = await GetInfoCustomerWithIdentityNumberIfHave(collectionInfo);

            InfoCustomer infoCustomerByPhoneAndIdentity = await GetInfoCustomerWithIdentityAndPhoneNumberIfHave(collectionInfo);

            if (infoCustomerByPhoneNumber != null && infoCustomerByIdentityNumber != null)
            {
                if (infoCustomerByPhoneAndIdentity.TransactionCode == carReturn.TransactionCode &&
                    !string.IsNullOrEmpty(infoCustomerByPhoneAndIdentity.TransactionCode) && !string.IsNullOrEmpty(carReturn.TransactionCode))
                {
                    return(new ConditionValidateDTO(StatusCondition.DENIED));
                }
            }

            if (infoCustomerByIdentityNumber != null)
            {
                InfoCustomerDTO inforReturn = Mapper.Map <InfoCustomerDTO>(infoCustomerByIdentityNumber);
                SetStatusForCustomerInforReturn(collectionInfo, infoCustomerByIdentityNumber, inforReturn);
                return(new ConditionValidateDTO(StatusCondition.ACCEPT_RE_NEW_BRIEF_INFOCUSTOMER_AND_CAR, inforReturn, carReturn));
            }

            if (infoCustomerByPhoneNumber != null)
            {
                InfoCustomerDTO inforReturn = Mapper.Map <InfoCustomerDTO>(infoCustomerByPhoneNumber);
                SetStatusForCustomerInforReturn(collectionInfo, infoCustomerByPhoneNumber, inforReturn);
                return(new ConditionValidateDTO(StatusCondition.ACCEPT_RE_NEW_BRIEF_INFOCUSTOMER_AND_CAR, inforReturn, carReturn));
            }

            if (infoCustomerByIdentityNumber == null && infoCustomerByPhoneNumber == null)
            {
                return(new ConditionValidateDTO(StatusCondition.ACCEPT_RE_NEW_BRIEF_CAR, null, carReturn));
            }

            return(new ConditionValidateDTO(StatusCondition.ACCEPT_NEW));
        }
コード例 #14
0
        public async Task <ConditionValidateDTO> ValidateConditionFirstAndSecondConditionWhenUpdate(CheckInforCollectionDTO collectionInfo)
        {
            FormatDataCheckCondition(collectionInfo);
            if (IsCustomerAndCarInCurrentTransaction(collectionInfo))
            {
                return(new ConditionValidateDTO(StatusCondition.ACCEPT_OLD_TRANSACTION_DETAIL));
            }

            if (string.IsNullOrEmpty(collectionInfo.IdentityNumber))
            {
                return(await ValidateFirstConditionWithPlateAndPhone(collectionInfo));
            }
            else
            {
                return(await ValidateFirstConditionWithPlateAndPhoneAndIdentity(collectionInfo));
            }
        }
コード例 #15
0
 public async Task <ConditionValidateDTO> ValidateConditionFirstAndSecondCondition(CheckInforCollectionDTO collectionInfo)
 {
     FormatDataCheckCondition(collectionInfo);
     if (string.IsNullOrEmpty(collectionInfo.IdentityNumber))
     {
         return(await ValidateFirstConditionWithPlateAndPhone(collectionInfo));
     }
     else
     {
         return(await ValidateFirstConditionWithPlateAndPhoneAndIdentity(collectionInfo));
     }
 }
        private async Task <ConditionValidateDTO> ValidateFirstConditionWithPlateAndPhone(CheckInforCollectionDTO collectionInfo)
        {
            //CarDTO carPLate = await GetCarInDataWareHouse(collectionInfo.PLate);

            //if (carPLate == null)
            //{
            //    return await ValidatePhoneWhenPLateNotFound(collectionInfo);
            //}
            //else
            //{
            //    return await ValidatePhoneWhenPLateFound(carPLate, collectionInfo);
            //}

            Car carPLate = GetCarQueryAndFilterByStatusActive().FirstOrDefault(x => x.Plate == collectionInfo.PLate);

            if (carPLate == null)
            {
                return(await ValidatePhoneWhenPLateNotFound(collectionInfo));
            }
            else
            {
                CarDTO carReturn = Mapper.Map <CarDTO>(carPLate);
                return(await ValidatePhoneWhenPLateFound(carReturn, collectionInfo));
            }
        }
        private async Task <ConditionValidateDTO> ValidateFirstConditionWithPlateAndPhoneAndIdentity(CheckInforCollectionDTO collectionInfo)
        {
            Car carPLate = GetCarQueryAndFilterByStatusActive().FirstOrDefault(x => x.Plate == collectionInfo.PLate);

            if (carPLate == null)
            {
                return(await ValidatePhoneAndIdentityWhenPLateNotFound(collectionInfo));
            }
            else
            {
                CarDTO carReturn = Mapper.Map <CarDTO>(carPLate);
                return(await ValidatePhoneAndIdentityWhenPLateFound(carReturn, collectionInfo));
            }
        }
        private async Task <ConditionValidateDTO> ValidatePhoneWhenPLateFound(CarDTO carReturn, CheckInforCollectionDTO collectionInfo)
        {
            InfoCustomer inforCustomer = await GetInfoCustomerWithIdentityAndPhoneNumberIfHave(collectionInfo);

            if (inforCustomer == null)
            {
                return(new ConditionValidateDTO(StatusCondition.ACCEPT_RE_NEW_BRIEF_CAR, null, carReturn));
            }
            else
            {
                InfoCustomerDTO inforReturn = Mapper.Map <InfoCustomerDTO>(inforCustomer);
                SetStatusForCustomerInforReturn(collectionInfo, inforCustomer, inforReturn);

                if (string.IsNullOrEmpty(inforCustomer.IdentityNumber))
                {
                    if (inforReturn.TransactionCode == carReturn.TransactionCode && !string.IsNullOrEmpty(inforReturn.TransactionCode) && !string.IsNullOrEmpty(carReturn.TransactionCode))
                    {
                        return(new ConditionValidateDTO(StatusCondition.DENIED));
                    }
                    return(new ConditionValidateDTO(StatusCondition.ACCEPT_RE_NEW_BRIEF_INFOCUSTOMER_AND_CAR, inforReturn, carReturn));
                }
                else
                {
                    if (inforReturn.TransactionCode == carReturn.TransactionCode && !string.IsNullOrEmpty(inforReturn.TransactionCode) && !string.IsNullOrEmpty(carReturn.TransactionCode))
                    {
                        CollectionCarDetailDTO detailInsurance = GetCollectionCarDetailMappingWithCustomer(carReturn.Plate, inforReturn);
                        return(ValidateSecondConditionWithPlateAndPhone(carReturn, inforReturn, collectionInfo, detailInsurance));
                    }
                    else
                    {
                        return(new ConditionValidateDTO(StatusCondition.ACCEPT_RE_NEW_BRIEF_INFOCUSTOMER_AND_CAR, inforReturn, carReturn));
                    }
                }
            }
        }
コード例 #19
0
 private void FormatDataCheckCondition(CheckInforCollectionDTO collectionInfo)
 {
     collectionInfo.CustomerPhone  = string.IsNullOrEmpty(collectionInfo.CustomerPhone) ? string.Empty : collectionInfo.CustomerPhone.Trim();
     collectionInfo.IdentityNumber = string.IsNullOrEmpty(collectionInfo.IdentityNumber) ? string.Empty : collectionInfo.IdentityNumber.Trim();
     collectionInfo.PLate          = string.IsNullOrEmpty(collectionInfo.PLate) ? string.Empty : collectionInfo.PLate.ToUpper().Trim();
 }