private ConditionValidateDTO ValidateSecondConditionWithPlateAndPhone(CarDTO carReturn, InfoCustomerDTO inforReturn, CheckInforCollectionDTO collectionInfo, CollectionCarDetailDTO detailInsurance) { CollectionCar sheetCar = _collectionCarRepository.FindAll().OrderByDescending(x => x.CreatedDate) .FirstOrDefault(x => x.CollectionSheet.InfoCustomerId == inforReturn.Id); CollectionSheet sheetCollection = _collectionSheetRepository.FindById(sheetCar.CollectionSheetId); if (sheetCar == null) { return(new ConditionValidateDTO(StatusCondition.ACCEPT_RE_NEW_BRIEF_INFOR_AND_CAR_INSURANCE, inforReturn, carReturn, detailInsurance)); } DateTime currentDate = DateTime.Now; if ((currentDate.Year - sheetCollection?.TransactionDate.Value.Year) <= 3) { return(new ConditionValidateDTO(StatusCondition.DENIED_BY_THREE_YEAR)); } 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_INFOR_AND_CAR_INSURANCE, inforReturn, carReturn, detailInsurance)); } }
private void InactiveOldCollectionSheet(CollectionSheetRequestDTO sheet) { CollectionSheet collectionSheet = _collectionSheetRepository .FirstOrDefault(x => x.Id == sheet.CollectionCar.CollectionSheet.Id); collectionSheet.Status = Status.InActive; _collectionSheetRepository.Update(collectionSheet); }
public CollectionCarRequest GetByCollectionId(long id) { CollectionSheet collectionSheet = _collectionSheetRepository.FindById(id); if (collectionSheet == null) { throw new UserException(ErrorStatusReturn.COLLECTION_SHEET_NOT_FOUND); } return(Mapper.Map <CollectionCarRequest>(collectionSheet)); }
private void CheckDateAllowedUpdate(CollectionSheetRequestDTO sheet) { int day = DateTime.Now.Day; int month = DateTime.Now.Month; DateTime lastOfThisMonth = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month)); CollectionSheet collectionSheet = _collectionSheetRepository .FirstOrDefault(x => x.Id == sheet.CollectionCar.CollectionSheet.Id); DateTime dateCompare = lastOfThisMonth.AddDays(-DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month)).Date; if (day >= 10 && collectionSheet.TransactionDate.Value.Date <= dateCompare) { throw new UserException(ErrorStatusReturn.OVERDUE_DATE_ALLOWED_UPDATE_INFO_CUSTOMER); } }
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); }