public IActionResult Find([FromQuery] string nome, [FromQuery] string sobreNome, [FromQuery] string regiao, [FromQuery] string nomeDaMae, [FromQuery] string nomeDoPai, [FromQuery] byte?generoId, [FromQuery] byte?escolaridadeId, [FromQuery] byte?etniaId) { var filter = new PessoaFilter { Nome = nome, SobreNome = sobreNome, Regiao = regiao, NomeDaMae = nomeDaMae, NomeDoPai = nomeDoPai, EscolaridadeId = escolaridadeId, EtniaId = etniaId, GeneroId = generoId }; try { var result = _service.List(filter); return(Ok(result)); } catch (Exception ex) { return(StatusCode(500, ex.Message)); } }
private SearchResult <PessoaDto> GetByFiltersWithCache(PessoaFilter filter, Func <PessoaFilter, PaginateResult <Pessoa>, IEnumerable <PessoaDto> > MapperDomainToDto) { var filterKey = filter.CompositeKey(); if (filter.ByCache) { if (this.cache.ExistsKey <SearchResult <PessoaDto> >(filterKey)) { return(this.cache.GetAndCast <SearchResult <PessoaDto> >(filterKey)); } } var queryBase = this.Pessoa.GetByFilters(filter); var dataList = PagingAndSorting(filter, queryBase, PaginationDefault); var result = MapperDomainToDto(filter, dataList); var summary = Summary(queryBase, dataList); var searchResult = new SearchResult <PessoaDto> { DataList = result, Summary = summary, }; if (filter.ByCache) { this.cache.Add(filterKey, searchResult); this.AddTagCache(filterKey); } return(searchResult); }
private PaginateResult <T> PagingAndSorting <T>(PessoaFilter filter, IQueryable <T> queryBase, Func <PessoaFilter, IQueryable <T>, PaginateResult <T>, PaginateResult <T> > PaginationDefault) where T : class { var querySorting = queryBase; if (filter.IsOrderByDynamic) { querySorting = queryBase.OrderByDynamic(filter); } var dataList = new PaginateResult <T> { ResultPaginatedData = querySorting, TotalCount = 0 }; if (filter.IsPagination) { if (filter.IsOrderByDynamic || filter.IsOrderByDomain) { return(dataList = querySorting.PaginateNew(filter)); } dataList = PaginationDefault(filter, querySorting, dataList); } return(dataList); }
public IQueryable<Pessoa> GetBySimplefilters(PessoaFilter filters) { var querybase = this.GetAll(this.DataAgregation(filters)) .WithBasicFilters(filters) .WithCustomFilters(filters); return querybase; }
protected IQueryable <Pessoa> SimpleFilters(PessoaFilter filters, IQueryable <Pessoa> queryBase) { var queryFilter = queryBase; if (filters.PessoaId.IsSent()) { queryFilter = queryFilter.Where(_ => _.PessoaId == filters.PessoaId); } if (filters.AssinaturaId.IsSent()) { queryFilter = queryFilter.Where(_ => _.AssinaturaId == filters.AssinaturaId); } if (filters.Nome.IsSent()) { queryFilter = queryFilter.Where(_ => _.Nome.Contains(filters.Nome)); } if (filters.DataCriacaoStart.IsSent()) { queryFilter = queryFilter.Where(_ => _.DataCriacao >= filters.DataCriacaoStart); } if (filters.DataCriacaoEnd.IsSent()) { filters.DataCriacaoEnd = filters.DataCriacaoEnd.AddDays(1).AddMilliseconds(-1); queryFilter = queryFilter.Where(_ => _.DataCriacao <= filters.DataCriacaoEnd); } if (filters.VisibilidadeId.IsSent()) { queryFilter = queryFilter.Where(_ => _.VisibilidadeId == filters.VisibilidadeId); } return(queryFilter); }
public async Task <Pessoa> GetById(PessoaFilter model) { var _pessoa = await this.SingleOrDefaultAsync(this.GetAll(this.DataAgregation(model)) .Where(_ => _.PessoaId == model.PessoaId)); return(_pessoa); }
public async Task <IActionResult> Get([FromQuery] PessoaFilter filters) { var result = new HttpResult <dynamic>(this._logger); try { if (filters.FilterBehavior == FilterBehavior.GetDataItem) { var searchResult = await this._rep.GetDataItem(filters); return(result.ReturnCustomResponse(searchResult, filters)); } if (filters.FilterBehavior == FilterBehavior.GetDataCustom) { var searchResult = await this._rep.GetDataCustom(filters); return(result.ReturnCustomResponse(searchResult, filters)); } if (filters.FilterBehavior == FilterBehavior.GetDataListCustom) { var searchResult = await this._rep.GetDataListCustom(filters); return(result.ReturnCustomResponse(searchResult, filters)); } throw new InvalidOperationException("invalid FilterBehavior"); } catch (Exception ex) { return(result.ReturnCustomException(ex, "Calemas.Erp - Pessoa", filters)); } }
public IQueryable <Pessoa> GetByFilters(PessoaFilter filters) { var querybase = this.GetAll(); var queryFilter = this.SimpleFilters(filters, querybase); return(queryFilter); }
public async Task <dynamic> GetDataCustom(PessoaFilter filters) { var querybase = await this.ToListAsync(this.GetBySimplefilters(filters).Select(_ => new { Id = _.PessoaId, })); return(querybase); }
public virtual dynamic GetDataCustom(PessoaFilter filters) { var result = this.GetByFilters(filters); return(result.Select(_ => new { PessoaId = _.PessoaId }).SingleOrDefault()); }
private PaginateResult <dynamic> PaginationDynamic(PessoaFilter filter, IQueryable <dynamic> querySorting, PaginateResult <dynamic> dataList) { if (filter.OrderFields.IsNull()) { filter.OrderFields = new[] { "CustomFieldOrder" }; filter.orderByType = Common.Enum.OrderByType.OrderByDescending; } dataList = querySorting.OrderByDynamic(filter).PaginateNew(filter); return(dataList); }
public IEnumerable <DataItem> GetDataItem(PessoaFilter filters) { var dataList = this.GetByFilters(filters) .Select(_ => new DataItem { Id = _.PessoaId.ToString(), }); return(dataList.ToList()); }
public async Task <IEnumerable <dynamic> > GetDataItem(PessoaFilter filters) { var querybase = await this.ToListAsync(this.GetBySimplefilters(filters).Select(_ => new { Id = _.PessoaId, Name = _.Nome })); return(querybase); }
public virtual IEnumerable <dynamic> GetDataListCustom(PessoaFilter filters) { var result = this.GetByFilters(filters); return(result.Select(_ => new { CustomFieldOrder = _.PessoaId, PessoaId = _.PessoaId })); }
public IQueryable <Pessoa> GetByFilters(PessoaFilter filters, params Expression <Func <Pessoa, object> >[] includes) { var queryBase = this.rep.GetAllAsTracking(includes); var queryFilter = queryBase; queryFilter = this.SimpleFilters(filters, queryBase); //Filter Customizados return(queryFilter); }
public SearchResult <PessoaDto> GetReport(PessoaFilter filter) { var result = default(SearchResult <PessoaDto>); using (var transaction = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = IsolationLevel.ReadUncommitted })) { result = GetByFiltersWithCache(filter, MapperDomainToReport); } return(result); }
public int GetTotalByFilters(PessoaFilter filter) { var result = default(int); using (var transaction = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = IsolationLevel.ReadUncommitted })) { result = this.Pessoa.GetByFilters(filter).Count(); } return(result); }
public dynamic GetDataCustom(PessoaFilter filters) { var result = default(dynamic); using (var transaction = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = IsolationLevel.ReadUncommitted })) { result = this.Pessoa.GetDataCustom(filters); } return(result); }
protected IQueryable <Pessoa> SimpleFilters(PessoaFilter filters, IQueryable <Pessoa> queryBase) { var queryFilter = queryBase; if (filters.PessoaId.IsSent()) { queryFilter = queryFilter.Where(_ => _.PessoaId == filters.PessoaId); } ; if (filters.Nome.IsSent()) { queryFilter = queryFilter.Where(_ => _.Nome.Contains(filters.Nome)); } ; if (filters.DataNascimentoStart.IsSent()) { queryFilter = queryFilter.Where(_ => _.DataNascimento >= filters.DataNascimentoStart); } ; if (filters.DataNascimentoEnd.IsSent()) { filters.DataNascimentoEnd = filters.DataNascimentoEnd.AddDays(1).AddMilliseconds(-1); queryFilter = queryFilter.Where(_ => _.DataNascimento <= filters.DataNascimentoEnd); } ; if (filters.Sexo.IsSent()) { queryFilter = queryFilter.Where(_ => _.Sexo == filters.Sexo); } ; if (filters.Ativo.IsSent()) { queryFilter = queryFilter.Where(_ => _.Ativo == filters.Ativo); } ; if (filters.DataCriacaoStart.IsSent()) { queryFilter = queryFilter.Where(_ => _.DataCriacao >= filters.DataCriacaoStart); } ; if (filters.DataCriacaoEnd.IsSent()) { filters.DataCriacaoEnd = filters.DataCriacaoEnd.AddDays(1).AddMilliseconds(-1); queryFilter = queryFilter.Where(_ => _.DataCriacao <= filters.DataCriacaoEnd); } ; return(queryFilter); }
public ActionResult Get([FromQuery] PessoaFilter filter, int pageNumber = 0, int pageSize = 0) { if (pageNumber > 0 && pageSize > 0) { var pessoas = _pessoaApplication.GetAll(filter, pageNumber, pageSize); return(GetResponse(pessoas)); } else { var pessoa = _pessoaApplication.GetBy(filter); return(GetResponse(pessoa)); } }
public async Task <IActionResult> Get([FromQuery] PessoaFilter filters) { var result = new HttpResult <PessoaDto>(this._logger); try { var searchResult = await this._app.GetByFilters(filters); return(result.ReturnCustomResponse(this._app, searchResult, filters)); } catch (Exception ex) { return(result.ReturnCustomException(ex, "Calemas.Erp - Pessoa", filters)); } }
public async Task <IActionResult> DataItems([FromQuery] PessoaFilter filters) { var result = new HttpResult <dynamic>(this._logger, this._service); try { var items = await this._service.GetDataItems(filters); return(result.ReturnCustomResponse(items)); } catch (Exception ex) { return(result.ReturnCustomException(ex, "Assinatura", filters)); } }
public async Task <IActionResult> Get([FromQuery] PessoaFilter filters) { var result = new HttpResult <PessoaDto>(this._logger, this._service); try { var searchResult = await this._service.GetByFiltersPaging(filters); return(result.ReturnCustomResponse(searchResult)); } catch (Exception ex) { return(result.ReturnCustomException(ex, "Pessoa", filters)); } }
public async Task <IActionResult> Get(int id, [FromQuery] PessoaFilter filters) { var result = new HttpResult <PessoaDto>(this._logger); try { filters.PessoaId = id; var returnModel = await this._app.GetOne(filters); return(result.ReturnCustomResponse(this._app, returnModel)); } catch (Exception ex) { return(result.ReturnCustomException(ex, "Calemas.Erp - Pessoa", id)); } }
public async Task <IActionResult> Get(int id, [FromQuery] PessoaFilter filters) { var result = new HttpResult <PessoaDto>(this._logger, this._service); try { filters.PessoaId = id; var returnModel = await this._service.GetById(filters); return(result.ReturnCustomResponse(returnModel)); } catch (Exception ex) { return(result.ReturnCustomException(ex, "Pessoa", id)); } }
public SearchResult <dynamic> GetDataListCustom(PessoaFilter filters) { var result = default(SearchResult <dynamic>); using (var transaction = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = IsolationLevel.ReadUncommitted })) { var queryBase = this.Pessoa.GetDataListCustom(filters); var dataList = PagingAndSorting <dynamic>(filters, queryBase.AsQueryable(), PaginationDynamic); result = new SearchResult <dynamic> { DataList = dataList.ResultPaginatedData.ToList(), Summary = this.Pessoa.GetSummaryDataListCustom(queryBase) }; } return(result); }
public IEnumerable <Pessoa> List(PessoaFilter filter) { var result = Connection.Query("SProc_Pessoa_GetByFilter", commandType: CommandType.StoredProcedure, param: new { filter.Nome, filter.SobreNome, filter.Regiao, filter.NomeDaMae, filter.NomeDoPai, filter.GeneroId, filter.EtniaId, filter.EscolaridadeId }); return(MapFromDB(result)); }
public async Task <IActionResult> Get([FromQuery] PessoaFilter filters) { var result = new HttpResult <dynamic>(this._logger); try { if (filters.FilterBehavior == FilterBehavior.GetDataItem) { var searchResult = await this._rep.GetDataItem(filters); return(result.ReturnCustomResponse(searchResult, filters)); } if (filters.FilterBehavior == FilterBehavior.GetDataCustom) { var searchResult = await this._rep.GetDataCustom(filters); return(result.ReturnCustomResponse(searchResult, filters)); } if (filters.FilterBehavior == FilterBehavior.GetDataListCustom) { var searchResult = await this._rep.GetDataListCustom(filters); return(result.ReturnCustomResponse(searchResult, filters)); } if (filters.FilterBehavior == FilterBehavior.Export) { var searchResult = await this._rep.GetDataListCustom(filters); var export = new ExportExcelCustom <dynamic>(filters); var file = export.ExportFile(this.Response, searchResult, "Pessoa"); return(File(file, export.ContentTypeExcel(), export.GetFileName())); } throw new InvalidOperationException("invalid FilterBehavior"); } catch (Exception ex) { return(result.ReturnCustomException(ex, "Calemas.Erp - Pessoa", filters)); } }
public HttpResponseMessage GetWarnings([FromUri] PessoaFilter filters) { var result = new HttpResult <PessoaDto>(); try { var token = HelperAuth.GetHeaderToken(); this.app = new PessoaApp(token); this.app.GetWarnings(filters); result.Warnings = this.app.ValidationHelper.GetDomainWarning(); this.app.Dispose(); result.Success(); return(Request.CreateResponse(result.StatusCode, result)); } catch (Exception ex) { result.ReturnCustomException(ex); return(Request.CreateResponse(result.StatusCode, result)); } }
public HttpResponseMessage GetDataListCustom([FromUri] PessoaFilter filter) { var result = new HttpResult <object>(); try { var token = HelperAuth.GetHeaderToken(); this.app = new PessoaApp(token); var searchResult = this.app.GetDataListCustom(filter); result.Summary = searchResult.Summary; result.Warnings = this.app.ValidationHelper.GetDomainWarning(); result.Success(searchResult.DataList); this.app.Dispose(); return(Request.CreateResponse(result.StatusCode, result)); } catch (Exception ex) { result.ReturnCustomException(ex); return(Request.CreateResponse(result.StatusCode, result)); } }