public async Task <Projeto> GetById(ProjetoFilter model)
        {
            var _projeto = await this.SingleOrDefaultAsync(this.GetAll(this.DataAgregation(model))
                                                           .Where(_ => _.ProjetoId == model.ProjetoId));

            return(_projeto);
        }
        public async Task <dynamic> GetDataCustom(ProjetoFilter filters)
        {
            var querybase = await this.ToListAsync(this.GetBySimplefilters(filters).Select(_ => new
            {
                Id = _.ProjetoId,
            }));

            return(querybase);
        }
        public async Task <IEnumerable <dynamic> > GetDataItem(ProjetoFilter filters)
        {
            var querybase = await this.ToListAsync(this.GetBySimplefilters(filters).Select(_ => new
            {
                Id   = _.ProjetoId,
                Name = _.Nome
            }));

            return(querybase);
        }
        public IQueryable <Projeto> GetBySimplefilters(ProjetoFilter filters)
        {
            var querybase = this.GetAll(this.DataAgregation(filters))
                            .WithBasicFilters(filters)
                            .WithLimitTenant(this._user)
                            .WithCustomFilters(filters)
                            .OrderByDomain(filters)
                            .OrderByProperty(filters);

            return(querybase);
        }
Beispiel #5
0
        public async Task <IActionResult> Get([FromQuery] ProjetoFilter filters)
        {
            var result = new HttpResult <ProjetoDto>(this._logger);

            try
            {
                var searchResult = await this._app.GetByFilters(filters);

                return(result.ReturnCustomResponse(this._app, searchResult, filters));
            }
            catch (Exception ex)
            {
                return(result.ReturnCustomException(ex, "Target.Pendencias - Projeto", filters));
            }
        }
Beispiel #6
0
        public async Task <IActionResult> Get(int id, [FromQuery] ProjetoFilter filters)
        {
            var result = new HttpResult <ProjetoDto>(this._logger);

            try
            {
                filters.ProjetoId = id;
                var returnModel = await this._app.GetOne(filters);

                return(result.ReturnCustomResponse(this._app, returnModel));
            }
            catch (Exception ex)
            {
                return(result.ReturnCustomException(ex, "Target.Pendencias - Projeto", id));
            }
        }
Beispiel #7
0
        public async Task <IActionResult> Get([FromQuery] ProjetoFilter 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, "Projeto");
                    return(File(file, export.ContentTypeExcel(), export.GetFileName()));
                }

                throw new InvalidOperationException("invalid FilterBehavior");
            }
            catch (Exception ex)
            {
                return(result.ReturnCustomException(ex, "Target.Pendencias - Projeto", filters));
            }
        }
        public virtual Task <PaginateResult <Projeto> > GetByFiltersPaging(ProjetoFilter filters)
        {
            var queryBase = this._rep.GetBySimplefilters(filters);

            return(this._rep.PagingAndDefineFields(filters, queryBase));
        }
        public virtual async Task <IEnumerable <Projeto> > GetByFilters(ProjetoFilter filters)
        {
            var queryBase = this._rep.GetBySimplefilters(filters);

            return(await this._rep.ToListAsync(queryBase));
        }
 public virtual async Task <Projeto> GetOne(ProjetoFilter filters)
 {
     return(await this._rep.GetById(filters));
 }
Beispiel #11
0
        public async Task <IEnumerable <dynamic> > GetDataListCustom(ProjetoFilter filters)
        {
            var queryPendenciaBase = this.ctx.Set <Pendencia>().AsQueryable();

            if (filters.Tags.IsNotNullOrEmpty())
            {
                queryPendenciaBase = queryPendenciaBase.Where(_ => _.Tags.Contains(filters.Tags));
            }

            var pendencias = await this.ToListAsync(queryPendenciaBase
                                                    .Include(_ => _.Usuario)
                                                    .Include(_ => _.CollectionPendenciaTempos)
                                                    .Select(_ => new
            {
                projetoId                 = _.ProjetoId,
                Pontos                    = _.PontosEstimados,
                Horas                     = _.TempoEstimado,
                DataConclusao             = _.DataConclusao,
                FluxoTrabalhoTipoId       = _.FluxoTrabalhoStatus.FluxoTrabalhoTipoId,
                UsuarioNome               = _.Usuario.Nome,
                CollectionPendenciaTempos = _.CollectionPendenciaTempos
            }));

            var projetoQueryBase = this.GetBySimplefilters(filters);

            if (filters.CollectionProjetoId.IsAny())
            {
                projetoQueryBase = projetoQueryBase.Where(_ => filters.CollectionProjetoId.Contains(_.ProjetoId));
            }

            var querybase = await this.ToListAsync(projetoQueryBase
                                                   .Select(_ => new
            {
                Id        = _.ProjetoId,
                Nome      = _.Nome,
                Descricao = _.Descricao,
                Visao     = _.Visao,
                Inicio    = _.Inicio,
                Fim       = _.Fim,
            }));



            var temp = querybase.Select(_ => new
            {
                Id              = _.Id,
                Nome            = _.Nome,
                Descricao       = _.Descricao,
                Visao           = _.Visao,
                Inicio          = _.Inicio,
                Fim             = _.Fim,
                Time            = pendencias.Where(__ => __.projetoId == _.Id).Select(__ => __.UsuarioNome).Distinct(),
                TotalPendencias = pendencias.Where(__ => __.projetoId == _.Id).Where(__ => __.FluxoTrabalhoTipoId == (int)EFluxoTrabalhoTipo.Aberto).Count(),
                TotalConcluidas = pendencias.Where(__ => __.projetoId == _.Id).Where(__ => __.FluxoTrabalhoTipoId == (int)EFluxoTrabalhoTipo.Concluido).Count(),
                TotalPontos     = pendencias.Where(__ => __.projetoId == _.Id).Select(__ => __.Pontos).Sum(),
                TotalHoras      = pendencias.Where(__ => __.projetoId == _.Id).Select(__ => __.Horas).Sum(),
                TotalHorasReais = pendencias.Where(__ => __.projetoId == _.Id).SelectMany(__ => __.CollectionPendenciaTempos.Select(___ => ___.TempoDecorrido)).Sum(),
            });

            if (filters.Tags.IsNotNullOrEmpty())
            {
                temp = temp.Where(_ => _.TotalPendencias > 0);
            }

            return(temp.Select(_ => new
            {
                Id = _.Id,
                Nome = _.Nome,
                Descricao = _.Descricao,
                Visao = _.Visao,
                Inicio = _.Inicio,
                Fim = _.Fim,
                Time = _.Time,
                TotalPendencias = _.TotalPendencias,
                TotalConcluidas = _.TotalConcluidas,
                TotalPontos = _.TotalPontos,
                TotalHoras = _.TotalHoras,
                TotalHorasReais = _.TotalHorasReais,
                BuningDown = this.BuningDown(_.Inicio, _.Fim, pendencias.Where(__ => __.projetoId == _.Id))
            }));
        }
Beispiel #12
0
 public static IQueryable <Projeto> OrderByDomain(this IQueryable <Projeto> queryBase, ProjetoFilter filters)
 {
     return(queryBase.OrderBy(_ => _.ProjetoId));
 }
Beispiel #13
0
        public static IQueryable <Projeto> WithCustomFilters(this IQueryable <Projeto> queryBase, ProjetoFilter filters)
        {
            var queryFilter = queryBase;


            return(queryFilter);
        }
Beispiel #14
0
        public static IQueryable <Projeto> WithBasicFilters(this IQueryable <Projeto> queryBase, ProjetoFilter filters)
        {
            var queryFilter = queryBase;

            if (filters.ProjetoId.IsSent())
            {
                queryFilter = queryFilter.Where(_ => _.ProjetoId == filters.ProjetoId);
            }
            if (filters.Nome.IsSent())
            {
                queryFilter = queryFilter.Where(_ => _.Nome.Contains(filters.Nome));
            }
            if (filters.Descricao.IsSent())
            {
                queryFilter = queryFilter.Where(_ => _.Descricao.Contains(filters.Descricao));
            }
            if (filters.Visao.IsSent())
            {
                queryFilter = queryFilter.Where(_ => _.Visao.Contains(filters.Visao));
            }
            if (filters.ClienteId.IsSent())
            {
                queryFilter = queryFilter.Where(_ => _.ClienteId == filters.ClienteId);
            }
            if (filters.UsuarioId.IsSent())
            {
                queryFilter = queryFilter.Where(_ => _.UsuarioId == filters.UsuarioId);
            }
            if (filters.ChaveUnica.IsSent())
            {
                queryFilter = queryFilter.Where(_ => _.ChaveUnica.Contains(filters.ChaveUnica));
            }
            if (filters.InicioStart.IsSent())
            {
                queryFilter = queryFilter.Where(_ => _.Inicio != null && _.Inicio.Value >= filters.InicioStart.Value);
            }
            if (filters.InicioEnd.IsSent())
            {
                filters.InicioEnd = filters.InicioEnd.Value.AddDays(1).AddMilliseconds(-1);
                queryFilter       = queryFilter.Where(_ => _.Inicio != null && _.Inicio.Value <= filters.InicioEnd);
            }

            if (filters.FimStart.IsSent())
            {
                queryFilter = queryFilter.Where(_ => _.Fim != null && _.Fim.Value >= filters.FimStart.Value);
            }
            if (filters.FimEnd.IsSent())
            {
                filters.FimEnd = filters.FimEnd.Value.AddDays(1).AddMilliseconds(-1);
                queryFilter    = queryFilter.Where(_ => _.Fim != null && _.Fim.Value <= filters.FimEnd);
            }

            if (filters.UserCreateId.IsSent())
            {
                queryFilter = queryFilter.Where(_ => _.UserCreateId == filters.UserCreateId);
            }
            if (filters.UserCreateDateStart.IsSent())
            {
                queryFilter = queryFilter.Where(_ => _.UserCreateDate >= filters.UserCreateDateStart);
            }
            if (filters.UserCreateDateEnd.IsSent())
            {
                filters.UserCreateDateEnd = filters.UserCreateDateEnd.AddDays(1).AddMilliseconds(-1);
                queryFilter = queryFilter.Where(_ => _.UserCreateDate <= filters.UserCreateDateEnd);
            }

            if (filters.UserAlterId.IsSent())
            {
                queryFilter = queryFilter.Where(_ => _.UserAlterId != null && _.UserAlterId.Value == filters.UserAlterId);
            }
            if (filters.UserAlterDateStart.IsSent())
            {
                queryFilter = queryFilter.Where(_ => _.UserAlterDate != null && _.UserAlterDate.Value >= filters.UserAlterDateStart.Value);
            }
            if (filters.UserAlterDateEnd.IsSent())
            {
                filters.UserAlterDateEnd = filters.UserAlterDateEnd.Value.AddDays(1).AddMilliseconds(-1);
                queryFilter = queryFilter.Where(_ => _.UserAlterDate != null && _.UserAlterDate.Value <= filters.UserAlterDateEnd);
            }



            return(queryFilter);
        }