public async Task <HttpResponseMessage> Get(CurrencySearchFilter filter) { HttpResponseMessage response = null; if (filter != null) { var session = (Session)ContextOperator.Get(ContextKeys.SESSION_ID); filter.CompanyId = session.CompanyId; var collection = this._currencyService.Get(filter); response = Request.CreateResponse(HttpStatusCode.OK, new ResponseMessage <object>(true, "Succeeded", collection)); } else { response = Request.CreateResponse(HttpStatusCode.OK, new ResponseMessage <object>(false, MessageString.INVALID_REQUEST_PARMS, null)); } return(await Task.Run(() => response)); }
public IEnumerable <Currency> Get(CurrencySearchFilter 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 <Currency, bool> > predicate = x => x.CompanyId == filter.CompanyId && (filter.Keyword == "*" || x.Code.StartsWith(filter.Keyword) || x.Name.StartsWith(filter.Keyword)); Expression <Func <Currency, bool> > statusFilter = s => s.IsActive == (filter.Active ?? true); if (filter.Active != null) { predicate = predicate.And(statusFilter); } return(this._currencyRepository.Find(predicate).Skip(filter.Start).Take(filter.Take).ToList()); } catch (Exception ex) { throw; } }