Exemplo n.º 1
0
        private void InactiveOldCollectionCar(CollectionSheetRequestDTO sheet)
        {
            CollectionCar collectionCar = _collectionCarRepository.FirstOrDefault(x => x.Id == sheet.CollectionCar.Id);

            collectionCar.Status = Status.InActive;
            _collectionCarRepository.Update(collectionCar);
        }
Exemplo n.º 2
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));
            }
        }
Exemplo n.º 3
0
        private void UpdateCollectionCar(CollectionCarDTO carSheet)
        {
            CollectionCar carSheetImport = Mapper.Map <CollectionCar>(carSheet);

            carSheetImport.Status    = Status.Active;
            carSheetImport.UpdatedBy = carSheet.UpdatedBy;
            _collectionCarRepository.Update(carSheetImport);
        }
Exemplo n.º 4
0
        private void InsertCollectionCar(CollectionCarDTO carSheet)
        {
            CollectionCar carSheetImport = Mapper.Map <CollectionCar>(carSheet);

            carSheetImport.Status    = Status.Active;
            carSheetImport.CreatedBy = carSheet.CreatedBy;
            _collectionCarRepository.Add(carSheetImport);
        }
        public CollectionSheetRequestDTO GetById(long id)
        {
            CollectionSheet collectionSheet = _collectionSheetRepository.FindById(id, n => n.InfoCustomer, n => n.TypeCollectionInfor);

            if (collectionSheet == null)
            {
                throw new UserException(ErrorStatusReturn.COLLECTION_SHEET_NOT_FOUND);
            }
            CollectionSheetRequestDTO resultCollection = Mapper.Map <CollectionSheetRequestDTO>(collectionSheet);

            CollectionCar collectionCar = _collectionCarRepository.FirstOrDefault(x => x.CollectionSheetId == id);

            if (collectionCar == null)
            {
                throw new UserException(ErrorStatusReturn.COLLECTION_SHEET_CAR_NOT_FOUND);
            }

            var collectionCarDetails = _collectionCarDetailRepository
                                       .FindAll(x => x.CollectionCarId == collectionCar.Id, x => x.Car).ProjectTo <CollectionCarDetailDTO>().ToList();

            resultCollection.CollectionCar = Mapper.Map <CollectionCarDTO>(collectionCar);
            resultCollection.CollectionCar.CollectionCarDetails = collectionCarDetails;
            return(resultCollection);
        }