Exemplo n.º 1
0
        public async Task <Turma> GetById(TurmaFilter model)
        {
            var _turma = await this.SingleOrDefaultAsync(this.GetAll(this.DataAgregation(model))
                                                         .Where(_ => _.TurmaId == model.TurmaId));

            return(_turma);
        }
Exemplo n.º 2
0
        public IEnumerable <Turma> FiltrarTurmas(TurmaFilter filter)
        {
            var query = Query()
                        .Include(x => x.Curso)
                        .Include(x => x.TipoStatusTurma)
                        .Include(x => x.TurmasProfessor).ThenInclude(x => x.Professor)
                        .AsQueryable();

            if (!string.IsNullOrEmpty(filter.Codigo))
            {
                query = query.Where(x => x.Codigo.Contains(filter.Codigo));
            }
            if (filter.CursoId.HasValue)
            {
                query = query.Where(x => x.CursoId == filter.CursoId);
            }
            if (filter.AnoInicio.HasValue)
            {
                query = query.Where(x => x.DataInicio.Year == filter.AnoInicio.Value.Year);
            }
            if (!filter.Concluidas)
            {
                query = query.Where(x => x.TipoStatusTurmaId == (int)TipoStatusTurmaEnum.EmAndamento);
            }

            return(query.OrderBy(x => x.Codigo).ToList());
        }
Exemplo n.º 3
0
        public async Task <dynamic> GetDataCustom(TurmaFilter filters)
        {
            var querybase = await this.ToListAsync(this.GetBySimplefilters(filters).Select(_ => new
            {
                Id = _.TurmaId
            }));

            return(querybase);
        }
Exemplo n.º 4
0
        public async Task <PaginateResult <dynamic> > GetDataListCustomPaging(TurmaFilter filters)
        {
            var querybase = await this.PagingDataListCustom <dynamic>(filters, this.GetBySimplefilters(filters).Select(_ => new
            {
                Id = _.TurmaId
            }));

            return(querybase);
        }
Exemplo n.º 5
0
        public async Task <IEnumerable <dynamic> > GetDataItem(TurmaFilter filters)
        {
            var querybase = await this.ToListAsync(this.GetBySimplefilters(filters).Select(_ => new
            {
                Id   = _.TurmaId,
                Name = _.CodigoDaTurma
            }));

            return(querybase);
        }
Exemplo n.º 6
0
        public IQueryable <Turma> GetBySimplefilters(TurmaFilter filters)
        {
            var querybase = this.GetAll(this.DataAgregation(filters))
                            .WithBasicFilters(filters)
                            .WithCustomFilters(filters)
                            .OrderByDomain(filters)
                            .OrderByProperty(filters);

            return(querybase);
        }
        public async Task <IActionResult> Get([FromQuery] TurmaFilter filters)
        {
            var result = new HttpResult <TurmaDto>(this._logger);

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

                return(result.ReturnCustomResponse(this._app, searchResult, filters));
            }
            catch (Exception ex)
            {
                var responseEx = result.ReturnCustomException(ex, "Seed - Turma", filters, new ErrorMapCustom());
                return(responseEx);
            }
        }
        public async Task <IActionResult> Get(int id, [FromQuery] TurmaFilter filters)
        {
            var result = new HttpResult <TurmaDto>(this._logger);

            try
            {
                if (id.IsSent())
                {
                    filters.TurmaId = id;
                }
                var returnModel = await this._app.GetOne(filters);

                return(result.ReturnCustomResponse(this._app, returnModel));
            }
            catch (Exception ex)
            {
                var responseEx = result.ReturnCustomException(ex, "Seed - Turma", id);
                return(responseEx);
            }
        }
        public static IQueryable <Turma> WithBasicFilters(this IQueryable <Turma> queryBase, TurmaFilter filters)
        {
            var queryFilter = queryBase;

            if (filters.Ids.IsSent())
            {
                queryFilter = queryFilter.Where(_ => filters.GetIds().Contains(_.TurmaId));
            }

            if (filters.TurmaId.IsSent())
            {
                queryFilter = queryFilter.Where(_ => _.TurmaId == filters.TurmaId);
            }
            if (filters.CodigoDaTurma.IsSent())
            {
                queryFilter = queryFilter.Where(_ => _.CodigoDaTurma.Contains(filters.CodigoDaTurma));
            }
            if (filters.Nome.IsSent())
            {
                queryFilter = queryFilter.Where(_ => _.Nome.Contains(filters.Nome));
            }
            if (filters.Descricao.IsSent())
            {
                queryFilter = queryFilter.Where(_ => _.Descricao.Contains(filters.Descricao));
            }
            if (filters.DataInicio.IsSent())
            {
                queryFilter = queryFilter.Where(_ => _.DataInicio >= filters.DataInicio.AddHours(-filters.DataInicio.Hour).AddMinutes(-filters.DataInicio.Minute).AddSeconds(-filters.DataInicio.Second) && _.DataInicio <= filters.DataInicio.AddDays(1).AddHours(-filters.DataInicio.Hour).AddMinutes(-filters.DataInicio.Minute).AddSeconds(-filters.DataInicio.Second));
            }
            if (filters.DataInicioStart.IsSent())
            {
                queryFilter = queryFilter.Where(_ => _.DataInicio >= filters.DataInicioStart);
            }
            if (filters.DataInicioEnd.IsSent())
            {
                filters.DataInicioEnd = filters.DataInicioEnd.AddDays(1).AddMilliseconds(-1);
                queryFilter           = queryFilter.Where(_ => _.DataInicio <= filters.DataInicioEnd);
            }

            if (filters.DataFim.IsSent())
            {
                queryFilter = queryFilter.Where(_ => _.DataFim >= filters.DataFim.AddHours(-filters.DataFim.Hour).AddMinutes(-filters.DataFim.Minute).AddSeconds(-filters.DataFim.Second) && _.DataFim <= filters.DataFim.AddDays(1).AddHours(-filters.DataFim.Hour).AddMinutes(-filters.DataFim.Minute).AddSeconds(-filters.DataFim.Second));
            }
            if (filters.DataFimStart.IsSent())
            {
                queryFilter = queryFilter.Where(_ => _.DataFim >= filters.DataFimStart);
            }
            if (filters.DataFimEnd.IsSent())
            {
                filters.DataFimEnd = filters.DataFimEnd.AddDays(1).AddMilliseconds(-1);
                queryFilter        = queryFilter.Where(_ => _.DataFim <= filters.DataFimEnd);
            }

            if (filters.AdmTurmaId.IsSent())
            {
                queryFilter = queryFilter.Where(_ => _.AdmTurmaId == filters.AdmTurmaId);
            }
            if (filters.StatusDaTurmaId.IsSent())
            {
                queryFilter = queryFilter.Where(_ => _.StatusDaTurmaId == filters.StatusDaTurmaId);
            }
            if (filters.UserAlterId.IsSent())
            {
                queryFilter = queryFilter.Where(_ => _.UserAlterId != null && _.UserAlterId.Value == filters.UserAlterId);
            }
            if (filters.UserAlterDate.IsSent())
            {
                queryFilter = queryFilter.Where(_ => _.UserAlterDate != null && _.UserAlterDate >= filters.UserAlterDate.Value.AddHours(-filters.UserAlterDate.Value.Hour).AddMinutes(-filters.UserAlterDate.Value.Minute).AddSeconds(-filters.UserAlterDate.Value.Second) && _.UserAlterDate <= filters.UserAlterDate.Value.AddDays(1).AddHours(-filters.UserAlterDate.Value.Hour).AddMinutes(-filters.UserAlterDate.Value.Minute).AddSeconds(-filters.UserAlterDate.Value.Second));
            }
            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);
            }

            if (filters.UserCreateId.IsSent())
            {
                queryFilter = queryFilter.Where(_ => _.UserCreateId == filters.UserCreateId);
            }
            if (filters.UserCreateDate.IsSent())
            {
                queryFilter = queryFilter.Where(_ => _.UserCreateDate >= filters.UserCreateDate.AddHours(-filters.UserCreateDate.Hour).AddMinutes(-filters.UserCreateDate.Minute).AddSeconds(-filters.UserCreateDate.Second) && _.UserCreateDate <= filters.UserCreateDate.AddDays(1).AddHours(-filters.UserCreateDate.Hour).AddMinutes(-filters.UserCreateDate.Minute).AddSeconds(-filters.UserCreateDate.Second));
            }
            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);
            }



            return(queryFilter);
        }
Exemplo n.º 10
0
 public IEnumerable <TurmaDTO> FiltrarTurmas(TurmaFilter filter)
 {
     return(TurmaService.FiltrarTurmas(filter));
 }
        public virtual Task <PaginateResult <Turma> > GetByFiltersPaging(TurmaFilter filters)
        {
            var queryBase = this._rep.GetBySimplefilters(filters);

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

            return(await this._rep.ToListAsync(queryBase));
        }
 public virtual async Task <Turma> GetOne(TurmaFilter filters)
 {
     return(await this._rep.GetById(filters));
 }
Exemplo n.º 14
0
        public async Task <IActionResult> Get([FromQuery] TurmaFilter 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 (!this._user.GetClaims().GetTools().VerifyClaimsCanRead("Turma"))
                {
                    return(new ObjectResult(null)
                    {
                        StatusCode = (int)HttpStatusCode.Forbidden
                    });
                }


                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.GetDataListCustomPaging)
                {
                    var paginatedResult = await this._rep.GetDataListCustomPaging(filters);

                    return(result.ReturnCustomResponse(paginatedResult.ToSearchResult <dynamic>(), 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, "Turma", this._env.RootPath);
                    return(File(file, export.ContentTypeExcel(), export.GetFileName()));
                }

                throw new InvalidOperationException("invalid FilterBehavior");
            }
            catch (Exception ex)
            {
                var responseEx = result.ReturnCustomException(ex, "Seed - Turma", filters, new ErrorMapCustom());
                return(responseEx);
            }
        }
Exemplo n.º 15
0
        public IEnumerable <TurmaDTO> FiltrarTurmas(TurmaFilter filter)
        {
            IEnumerable <Turma> turmas = turmaRepository.FiltrarTurmas(filter);

            return(turmas.Select(x => new TurmaDTO(x)));
        }
Exemplo n.º 16
0
        public static IQueryable <Turma> WithCustomFilters(this IQueryable <Turma> queryBase, TurmaFilter filters)
        {
            var queryFilter = queryBase;


            return(queryFilter);
        }
Exemplo n.º 17
0
 public static IQueryable <Turma> OrderByDomain(this IQueryable <Turma> queryBase, TurmaFilter filters)
 {
     return(queryBase.OrderBy(_ => _.TurmaId));
 }