Example #1
0
        public async Task <BaseViewModel <PagingResult <StoreViewModel> > > GetAllNearestStore(GetNearestStoreRequestViewmovel request, string defaultCondition = null)
        {
            var pageSize  = request.PageSize;
            var pageIndex = request.PageIndex;
            var result    = new BaseViewModel <PagingResult <StoreViewModel> >();



            var data = await _repository.GetAllNearestStore(request.Latitude, request.Longitude, request.Radius, pageSize *(pageIndex - 1), pageSize);

            //var sql = data.ToSql();

            if (data == null || data.Count == 0)
            {
                result.Description = MessageHandler.CustomMessage(MessageConstants.NO_RECORD);
                result.Code        = MessageConstants.NO_RECORD;
            }
            else
            {
                var pageSizeReturn = pageSize;
                if (data.Count < pageSize)
                {
                    pageSizeReturn = data.Count;
                }
                result.Data = new PagingResult <StoreViewModel>
                {
                    Results   = _mapper.Map <IEnumerable <StoreViewModel> >(data),
                    PageIndex = pageIndex,
                    PageSize  = pageSizeReturn,
                };
                foreach (var item in result.Data.Results)
                {
                    var listPromo = _promotionRepository.GetMany(_ => _.BrandId == item.BrandId && _.IsActive == true);
                    item.Promotions = _mapper.Map <ICollection <PromotionViewModel> >(listPromo);
                }
            }

            return(result);
        }
Example #2
0
        public async Task <ActionResult <BaseViewModel <PagingResult <StoreViewModel> > > > Getstore([FromQuery] GetNearestStoreRequestViewmovel request)
        {
            request.SetDefaultPage();
            //var a = request.Filters[0];

            var result = await _storeService.GetAllNearestStore(request);

            this.HttpContext.Response.StatusCode = (int)result.StatusCode;

            return(result);
        }