public IActionResult SearchHotelMerchantMgt([FromQuery] HotelMerchantMgtSearchModel model)
        {
            var response = _hotelMerchantMgtService.SearchHotelMerchantMgt(model);

            if (response != null)
            {
                return(Ok(response));
            }
            return(BadRequest());
        }
Пример #2
0
        public IPagedList <HotelMerchantMgtViewModel> SearchHotelMerchantMgt(HotelMerchantMgtSearchModel model)
        {
            var sortString       = !string.IsNullOrEmpty(model.SortString) ? model.SortString : $"{nameof(HotelMerchantAqmgts.CreatedDate)} Desc";
            var lstHotelMerchant = new PagedList <HotelMerchantMgtViewModel>();
            var userGuid         = _workContext.UserGuid;
            var userRoleId       = _workContext.UserRoleId;

            var query = (from hmmgt in _dbYachtContext.YachtMerchantAqmgts.AsNoTracking()
                         join hm in _dbYachtContext.YachtMerchants.AsNoTracking() on hmmgt.MerchantFid equals hm.Id
                         where hmmgt.Deleted == false && hm.Deleted == false &&
                         (userRoleId == (int)UserRoleEnum.YachtMerchantManager ? hmmgt.AqadminUserFid == userGuid : true) &&
                         (string.IsNullOrEmpty(model.AqadminUserFid) || hmmgt.AqadminUserFid.ToString().Contains(model.AqadminUserFid)) &&
                         (model.MerchantFid == 0 || hmmgt.MerchantFid == model.MerchantFid) &&
                         (string.IsNullOrEmpty(model.EffectiveStartDate) || Convert.ToDateTime(model.EffectiveStartDate) <= hmmgt.EffectiveStartDate) &&
                         (string.IsNullOrEmpty(model.EffectiveEndDate) || Convert.ToDateTime(model.EffectiveEndDate) >= hmmgt.EffectiveEndDate)
                         select _mapper.Map <HotelMerchantMgtViewModel>(hmmgt)).OrderBy(sortString).AsQueryable();

            if (query.Count() > 0)
            {
                lstHotelMerchant = new PagedList <HotelMerchantMgtViewModel>(query, model.PageIndex, model.PageSize);
            }

            return(lstHotelMerchant);
        }