Esempio n. 1
0
        public IActionResult GetYachtByMerchantIDForLanding(SearchYachtWithMerchantIdModel searchModel)
        {
            var result = _yachtLandingService.GetYachtByMerchantIDForLanding(searchModel);

            return(Ok(result));
        }
Esempio n. 2
0
        //*****modified by hoangle 10-10-2019
        //*****next modified by
        public IActionResult GetRestaurantsByMerchantFId([FromQuery] SearchYachtWithMerchantIdModel searchModel)
        {
            var result = _yachtService.GetYachtsByMerchantFId(searchModel);

            return(Ok(result));
        }
Esempio n. 3
0
        public BaseResponse <PagedList <YachtLandingViewModel> > GetYachtByMerchantIDForLanding(SearchYachtWithMerchantIdModel searchModel)
        {
            try
            {
                var sortString = !string.IsNullOrEmpty(searchModel.SortString)
                ? searchModel.SortString
                : "Name DESC";

                searchModel.PageIndex = searchModel.PageIndex > 0 ? searchModel.PageIndex : 1;
                searchModel.PageSize  = searchModel.PageSize > 0 ? searchModel.PageSize : 10;
                //var q = _aQYachtContext.Yachts.AsNoTracking()
                //        .Join(_aQYachtContext.YachtMerchants, x => x.MerchantFid, y => y.Id, (x, y) => new { x.Id, y.MerchantName })
                //        //.Select(xy => _mapper.Map<YachtLandingViewModel>(xy))
                //        //.Select(y => _mapper.Map<YachtLandingViewModel>(y))
                //        .ToList();
                _aQYachtContext.Yachts.AsNoTracking().Where(x => x.MerchantFid == searchModel.MerchantId.ToInt32()).Load();

                var yachtLst = _aQYachtContext.Yachts.AsNoTracking().Where(x => x.Deleted == false).ToList();

                var query = (from a in yachtLst
                             join b in _aQYachtContext.YachtMerchants.AsNoTracking().Where(x => x.Deleted == false) on a.MerchantFid equals b.Id
                             where a.MerchantFid == searchModel.MerchantId.ToInt32()
                             select _mapper.Map <(Yachts, YachtMerchants), YachtLandingViewModel>((a, b))).ToList();
                if (query != null)
                {
                    if (_aQYachtContext.YachtMerchantFileStreams.AsNoTracking().Any(x => x.MerchantFid == searchModel.MerchantId.ToInt32()))
                    {
                        query.ForEach(k => k.MerchantFileStreamId = _aQYachtContext.YachtMerchantFileStreams.AsNoTracking().Where(x => x.MerchantFid == k.MerchantFid && x.Deleted == false && x.ActivatedDate <= DateTime.Now).OrderByDescending(x => x.ActivatedDate).FirstOrDefault().FileStreamFid);
                    }

                    query.ForEach(k => k.YachtFileStreamId = _aQYachtContext.YachtFileStreams.AsNoTracking().Where(x => x.YachtFid == x.Id && (x.FileTypeFid == 4 || x.FileTypeFid == 5) && x.Deleted == false && x.ActivatedDate <= DateTime.Now).FirstOrDefault().FileStreamFid);
                }
                return(BaseResponse <PagedList <YachtLandingViewModel> > .Success(new PagedList <YachtLandingViewModel>(query, searchModel.PageIndex, searchModel.PageSize)));
            }
            catch (Exception ex)
            {
                return(BaseResponse <PagedList <YachtLandingViewModel> > .InternalServerError(new PagedList <YachtLandingViewModel>(Enumerable.Empty <YachtLandingViewModel>().AsQueryable(), searchModel.PageIndex, searchModel.PageSize), message : ex.Message, fullMsg : ex.StackTrace));
            }
        }