Exemplo n.º 1
0
        public IEnumerable <QuotationsMotorRequest> GetQuotations(QuotationRequestDto req)
        {
            Expression <Func <QuotationsMotorRequest, bool> > predicate = c => true;

            if (!string.IsNullOrEmpty(req.InsuredFirstName))
            {
                predicate = predicate.And(p => p.InsuredFirstName == req.InsuredFirstName);
            }
            if (!string.IsNullOrEmpty(req.InsuredFirstNameAr))
            {
                predicate = predicate.And(p => p.InsuredFirstNameAr == req.InsuredFirstNameAr);
            }
            if (req.DateFrom != null && req.DateTo != null)
            {
                predicate = predicate.And(p => p.CreatedDate.Date >= req.DateFrom.Value.Date && p.CreatedDate.Date <= req.DateFrom.Value.Date);
            }
            if (req.InsuredIdentityNumber != null)
            {
                predicate = predicate.And(p => p.InsuredIdentityNumber == req.InsuredIdentityNumber);
            }

            if (req.InsuredNationalityId != null)
            {
                predicate = predicate.And(p => p.InsuredNationalityId == req.InsuredNationalityId);
            }

            var data = this.GetMany(predicate)
                       .Include("VehicleIdType").Include("VehiclePlateFirstLetter")
                       .Include("VehiclePlateSecondLetter").Include("VehiclePlateThirsdLetter")
                       .Include("VehiclePlateType").Include("VehicleMaker").Include("VehicleModel").Include("VehicleMajorColor")
                       .Include("VehicleBodyType").Include("VehicleRegistrationCity").Include("VehicleRepairMethod").Include("VehicleUse")
                       .Include("VehicleTransmissionType").Include("VehicleAxleWeight");

            return(data);
        }
Exemplo n.º 2
0
        public IActionResult GetQuotationsRequest([FromBody] QuotationRequestDto req)
        {
            var data = unitOfWork.ClientQuotation.GetQuotations(req);

            if (data == null)
            {
                return(NotFound(new BaseResponse(false, 404, "Previous request data was not found")));
            }
            int pageSize   = req.PageSize ?? configuration.GetValue <int>("PagingOptions:PageSize");
            int pageNumber = req.PageNumber ?? configuration.GetValue <int>("PagingOptions:PageNumber");

            QuotationsMotorResponseDto response = new QuotationsMotorResponseDto()
            {
                Data            = mapper.Map <IEnumerable <ClientQuotationMotor>, IEnumerable <ClientQuotationsMotorDto> >(PagingList.Create(data, pageSize, pageNumber)),
                TotalRecord     = data.Count(),
                IsSuccess       = true,
                StatusCode      = (int)HttpStatusCode.OK,
                ResponseMessage = "Request has been complited successfully"
            };

            return(Ok(response));
        }