private List <YachtTourNonOperationDayViewModel> LoadYachtName(List <YachtTourNonOperationDayViewModel> models) { foreach (var item in models) { var yachtId = item.YachtFid.Decrypt().ToInt32(); var yacht = _yachtService.GetYachtBasicProfile(yachtId); if (yacht != null) { item.YachtName = yacht.ResponseData?.YachtName; } } return(models); }
public IActionResult GetBasicProfile(int yachtId) { var result = _yachtService.GetYachtBasicProfile(yachtId); if (result.IsSuccessStatusCode) { return(Ok(result)); } return(BadRequest()); }
private List <YachtBasicProfileModel> GetListYachtByTourId(int tourId) { var listTours = _yachtTourOperationDetailService.FindByTourId(tourId); var listYacht = listTours.IsSuccessStatusCode ? listTours.ResponseData .Select(k => _yachtService.GetYachtBasicProfile(k.YachtFid.Decrypt().ToInt32())?.ResponseData) .ToList() : new List <YachtBasicProfileModel>(); return(listYacht); }
public BaseResponse <List <YachtTourPricingDetailModel> > GetDetailByTourId(int tourId) { try { if (tourId < 1) { return(BaseResponse <List <YachtTourPricingDetailModel> > .BadRequest()); } var listTourPricings = _db.YachtTourPricings .AsNoTracking() .Where(k => !k.Deleted && k.TourFid == tourId) .ToList(); var listYachtIds = listTourPricings .Select(k => k.YachtFid) .Distinct() .ToList(); var listPricingDetails = new List <YachtTourPricingDetailModel>(); foreach (var yachtId in listYachtIds) { var yacht = _yachtService.GetYachtBasicProfile(yachtId); if (yacht != null) { var currentPricing = listTourPricings .Where(k => k.YachtFid == yachtId && (k.EffectiveDate.Date <= DateTime.Now.Date)) .Select(k => _mapper.Map <YachtTourPricings, YachtTourPricingViewModel>(k)) .OrderByDescending(k => k.EffectiveDate) .FirstOrDefault(); listPricingDetails.Add(new YachtTourPricingDetailModel() { Yacht = yacht.ResponseData, CurrentPricing = currentPricing }); } } return(BaseResponse <List <YachtTourPricingDetailModel> > .Success(listPricingDetails)); } catch (Exception ex) { return(BaseResponse <List <YachtTourPricingDetailModel> > .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace)); } }