public OrderPatternViewModel GetOrderPattern(string custMainCode, string custSubCode, string orderPatternC, DateTime?date) { var pattern = _orderPatternRepository.Query(pat => pat.CustomerMainC == custMainCode && pat.CustomerSubC == custSubCode && pat.OrderPatternC.Equals(orderPatternC)).FirstOrDefault(); if (pattern == null) { return(null); } var destination = Mapper.Map <OrderPattern_M, OrderPatternViewModel>(pattern); var customer = _customerRepository.Query( p => p.CustomerMainC == destination.CustomerMainC && p.CustomerSubC == destination.CustomerSubC) .FirstOrDefault(); destination.CustomerN = customer != null ? customer.CustomerN : String.Empty; var shippingCompany = _shippingCompanyRepository.Query(p => p.ShippingCompanyC == destination.ShippingCompanyC).FirstOrDefault(); destination.ShippingCompanyN = shippingCompany != null ? shippingCompany.ShippingCompanyN : String.Empty; var vessel = _vesselRepository.Query(p => p.VesselC == destination.VesselC).FirstOrDefault(); destination.VesselN = vessel != null ? vessel.VesselN : String.Empty; var shipper = _shipperRepository.Query(p => p.ShipperC == destination.ShipperC).FirstOrDefault(); destination.ShipperN = shipper != null ? shipper.ShipperN : String.Empty; var locLoadingPlace = _locationRepository.Query(p => p.LocationC == destination.LoadingPlaceC).FirstOrDefault(); destination.LoadingPlaceN = locLoadingPlace != null ? locLoadingPlace.LocationN : String.Empty; var locStopoverPlace = _locationRepository.Query(p => p.LocationC == destination.StopoverPlaceC).FirstOrDefault(); destination.StopoverPlaceN = locStopoverPlace != null ? locStopoverPlace.LocationN : String.Empty; var locDischargePlace = _locationRepository.Query(p => p.LocationC == destination.DischargePlaceC).FirstOrDefault(); destination.DischargePlaceN = locDischargePlace != null ? locDischargePlace.LocationN : String.Empty; var conttainertype = _containerTypeRepository.Query(p => p.ContainerTypeC == destination.ContainerTypeC).FirstOrDefault(); destination.ContainerTypeN = conttainertype != null ? conttainertype.ContainerTypeN : String.Empty; destination.PatternIndex = FindIndex(custMainCode, custSubCode, orderPatternC); //get list of contract tariff pattern destination.ContractTariffPatterns = _contractTariffPatternService.GetContractTariffPatterns(destination.CustomerMainC, destination.CustomerSubC, destination.LoadingPlaceC, destination.DischargePlaceC, date); return(destination); }
public IEnumerable <VesselViewModel> GetVesseles(string value) { var vesseles = _vesselRepository.Query(i => (i.VesselC.Contains(value) || i.VesselN.Contains(value)) && i.IsActive == Constants.ACTIVE); if (vesseles != null) { var destination = Mapper.Map <IEnumerable <Vessel_M>, IEnumerable <VesselViewModel> >(vesseles); return(destination); } return(null); }