Exemplo n.º 1
0
        public IEnumerable <Store> Get(StoreSearchFilter filter)
        {
            try
            {
                if (filter == null)
                {
                    throw new ArgumentNullException("filter");
                }

                if (string.IsNullOrEmpty(filter.CompanyId))
                {
                    throw new ArgumentNullException("CompanyId");
                }

                if (string.IsNullOrEmpty(filter.Keyword))
                {
                    filter.Keyword = "*";
                }

                if (filter.Take <= 0)
                {
                    filter.Take = 100;
                }

                Expression <Func <Store, bool> > predicate = x =>
                                                             x.CompanyId == filter.CompanyId && x.Status == (byte)StatusType.Active &&
                                                             (filter.Keyword == "*" || x.Name.StartsWith(filter.Keyword) || x.Street.StartsWith(filter.Keyword) || x.City.StartsWith(filter.Keyword) || x.State.StartsWith(filter.Keyword));

                return(this._storeRepository.Find(predicate).Skip(filter.Start).Take(filter.Take).ToList());
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemplo n.º 2
0
 public virtual ActionResult Manage(StoreSearchFilter filter)
 {
     if (!Request.IsAjaxRequest())
     {
         return(View(_storeSrv.Get(filter)));
     }
     else
     {
         return(PartialView("Partials/_List", _storeSrv.Get(filter)));
     }
 }
Exemplo n.º 3
0
        public async Task <HttpResponseMessage> Get(StoreSearchFilter filter)
        {
            if (filter != null)
            {
                var session = (Session)ContextOperator.Get(ContextKeys.SESSION_ID);
                filter.CompanyId = session.CompanyId;
                filter.UserId    = session.UserId;
                var collection = await Task.Run(() => { return(this._storeService.Get(filter)); });

                return(Request.CreateResponse(HttpStatusCode.OK, new ResponseMessage <object>(true, "Succeeded", collection)));
            }
            return(Request.CreateResponse(HttpStatusCode.OK, new ResponseMessage <object>(false, MessageString.INVALID_REQUEST_PARMS, null)));
        }
Exemplo n.º 4
0
        public PagingListDetails <Store> Get(StoreSearchFilter filter)
        {
            Expression <Func <Store, bool> > conditions = x => !x.IsDeleted;

            if (filter != null)
            {
                if (filter.UserId != null)
                {
                    conditions = conditions.And(x => x.UserId == filter.UserId);
                }
                if (!string.IsNullOrWhiteSpace(filter.Name))
                {
                    conditions = conditions.And(x => x.FullName.Contains(filter.Name));
                }
            }

            return(_storeRepo.Get(conditions, filter, x => x.OrderByDescending(i => i.StoreId), new List <Expression <Func <Store, object> > > {
                x => x.User
            }));
        }