Пример #1
0
        public IActionResult SearchDetail(string tourId, [FromBody] YachtTourPricingSearchModel model)
        {
            var tourIdDecrypted = tourId.Decrypt().ToInt32();

            if (tourIdDecrypted < 1)
            {
                return(BadRequest());
            }
            var result = _yachtTourPricingService.SearchDetail(tourIdDecrypted, model);

            if (result.IsSuccessStatusCode)
            {
                return(Ok(result));
            }
            return(BadRequest());
        }
Пример #2
0
 public BaseResponse <PagedList <YachtTourPricingDetailModel> > SearchDetail(int tourId, YachtTourPricingSearchModel model)
 {
     try
     {
         if (model == null)
         {
             return(BaseResponse <PagedList <YachtTourPricingDetailModel> > .BadRequest());
         }
         var pageSize   = model.PageSize > 0 ? model.PageSize : 10;
         var pageIndex  = model.PageIndex > 0 ? model.PageIndex : 1;
         var sortColumn = !string.IsNullOrEmpty(model.SortColumn) ? model.SortColumn : "YachtName";
         var sortType   = !string.IsNullOrEmpty(model.SortType) ? model.SortType : "DESC";
         var sortString = $"{sortColumn} {sortType}";
         var query      = (from o in _db.YachtTourOperationDetails.Where(k => !k.Deleted && k.TourFid == tourId)
                           join y in _db.Yachts.Where(k => !k.Deleted) on o.YachtFid equals y.Id
                           select new YachtBasicProfileModel()
         {
             YachtId = y.Id,
             YachtUniqueId = y.UniqueId,
             MerchantId = y.MerchantFid,
             YachtName = y.Name
         }).OrderBy(sortString);
         var allYachsOfTour    = query.ToList();
         var allPricingDetails = new List <YachtTourPricingDetailModel>();
         foreach (var yacht in allYachsOfTour)
         {
             var currentPricing = GetCurrentPricingByTourIdAndYachtId(tourId, yacht.YachtId);
             if (currentPricing != null)
             {
                 allPricingDetails.Add(new YachtTourPricingDetailModel()
                 {
                     Yacht          = yacht,
                     CurrentPricing = currentPricing
                 });
             }
         }
         var totalItems = allPricingDetails.Count();
         var result     = allPricingDetails
                          .Skip(pageSize * (pageIndex - 1))
                          .Take(pageSize)
                          .ToList();
         var pagedList = new PagedList <YachtTourPricingDetailModel>(result, totalItems, pageIndex, pageSize);
         return(BaseResponse <PagedList <YachtTourPricingDetailModel> > .Success(pagedList));
     }
     catch (Exception ex)
     {
         return(BaseResponse <PagedList <YachtTourPricingDetailModel> > .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace));
     }
 }
Пример #3
0
 public BaseResponse <PagedList <YachtTourPricingViewModel> > Search(int tourId, YachtTourPricingSearchModel model)
 {
     try
     {
         var pageSize  = model.PageSize > 0 ? model.PageSize : 10;
         var pageIndex = model.PageIndex > 0 ? model.PageIndex : 1;
         var query     = (from i in _db.YachtTourPricings
                          join y in _db.Yachts on i.YachtFid equals y.Id
                          where !i.Deleted && !y.Deleted && i.TourFid == tourId
                          select new YachtTourPricingViewModel()
         {
             Id = i.Id,
             YachtFid = Terminator.Encrypt(i.YachtFid.ToString()),
             YachtName = y.Name,
             TourFid = Terminator.Encrypt(i.TourFid.ToString()),
             TourPricingTypeResKey = i.TourPricingTypeResKey,
             EffectiveDate = i.EffectiveDate,
             EffectiveEndDate = i.EffectiveEndDate,
             TourFee = i.TourFee,
         }).OrderBy(x => x.YachtName).ThenBy(x => x.EffectiveDate);
         var result = new PagedList <YachtTourPricingViewModel>(query, pageIndex, pageSize);
         if (result != null)
         {
             return(BaseResponse <PagedList <YachtTourPricingViewModel> > .Success(result));
         }
         return(BaseResponse <PagedList <YachtTourPricingViewModel> > .BadRequest());
     }
     catch (Exception ex)
     {
         return(BaseResponse <PagedList <YachtTourPricingViewModel> > .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace));
     }
 }