Ejemplo n.º 1
0
        public async Task <PaginatedDto <RoleDto> > GetAllAsync(string name = null, string clientId = null, IEnumerable <string> roleIds = null, bool withPerms = false, IEnumerable <string> allowedClientIds = null, string excludeOrgId = null, IEnumerable <string> excludeRoleIds = null, int pageSize = 10, int pageIndex = 1)
        {
            var roles = await _roleRepo.GetAllAsync(name, clientId, roleIds, withPerms, allowedClientIds, excludeOrgId, pageSize, pageIndex);

            if (excludeRoleIds != null && excludeRoleIds.Any())
            {
                roles.Data = roles.Data.Where(itm => !excludeRoleIds.Contains(itm.Id));
            }

            PaginatedDto <RoleDto> result = new PaginatedDto <RoleDto>
            {
                Data = roles.Data?.Select(itm => new RoleDto
                {
                    Id           = itm.Id,
                    ClientId     = itm.ClientId,
                    Name         = itm.Name,
                    Desc         = itm.Description,
                    IsSuperAdmin = itm.IsSuperAdmin,
                    IsAdmin      = itm.IsSuperAdmin ? true : itm.IsAdmin,
                    Permissions  = Map(itm.Permissions, itm.ClientId),
                    CreatedAt    = itm.CreatedAt.ToString("yyyy-MM-dd HH:mm:ss")
                }),
                Total     = roles.Total,
                PageIndex = roles.PageIndex,
                PageSize  = roles.PageSize
            };

            return(result);
        }
        // GET api/countries?pageindex=1&pagesize=5
        public PaginatedDto <CountryDto> GetCountries(int pageIndex, int pageSize)
        {
            PaginatedList <Country>   countries           = _countryRepository.Paginate(pageIndex, pageSize);
            PaginatedDto <CountryDto> countryPaginatedDto = _mapper.Map <PaginatedList <Country>, PaginatedDto <CountryDto> >(countries);

            return(countryPaginatedDto);
        }
Ejemplo n.º 3
0
        public PaginatedDto <GenreDto> GetGenres(int pageIndex, int pageSize)
        {
            //return _genreRepository.GetAll();
            PaginatedList <Genre>   entities = _genreRepository.Paginate(pageIndex, pageSize);
            PaginatedDto <GenreDto> dtos     = _mapper.Map <PaginatedList <Genre>, PaginatedDto <GenreDto> >(entities);

            return(dtos);
        }
Ejemplo n.º 4
0
        public async Task <ViewResult> Index(int page = 1)
        {
            PaginatedDto <ShipmentDto> shipments =
                await _shipmentsClient.GetShipmentsAsync(
                    new PaginatedRequestCommand(page, DefaultPageSize));

            return(View(shipments));
        }
Ejemplo n.º 5
0
        public IActionResult GetTelemetryHistory([FromRoute] int id, [FromQuery] TelemetryFilter filter, int rowsPerPage = 20, int pageNumber = 1)
        {
            PaginatedElement <Telemetry> telemetries = telemetryService.GetByPool(id, filter, rowsPerPage, pageNumber);

            PaginatedDto <TelemetryDto> dto = mapper.Map <PaginatedDto <TelemetryDto> >(telemetries);

            dto.NextPageUrl = HttpContext.GetNextPageUrl(pageNumber < dto.PageCount);

            return(Ok(dto));
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> GetAlarms([FromRoute] int id, [FromQuery] AlarmFilter filter, [FromQuery] int rowsPerPage = 20, [FromQuery] int pageNumber = 1)
        {
            string userEmail = User.FindFirst(ClaimTypes.Email).Value;
            User   user      = await userManager.FindByEmailAsync(userEmail);

            PaginatedElement <Alarm> alarms = alarmService.GetByPool(id, filter, rowsPerPage, pageNumber, user);

            PaginatedDto <AlarmDto> dto = mapper.Map <PaginatedDto <AlarmDto> >(alarms);

            return(Ok(dto));
        }
Ejemplo n.º 7
0
        // private helpers
        private async Task GetAndSetShipmentTypesAsync()
        {
            PaginatedDto <ShipmentTypeDto> shipmentTypes =
                await _shipmentTypesClient.GetShipmentTypesAsync(new PaginatedRequestCommand(1, 50));

            ViewBag.ShipmentTypes = shipmentTypes.Items.Select(x => new SelectListItem()
            {
                Text  = x.Name,
                Value = x.Key.ToString()
            });
        }
        // GET api/countries?pageindex=1&pagesize=5
        public async Task <PaginatedDto <CountryDto> > GetCountries(int pageIndex, int pageSize)
        {
            var countries = await _countryService.SearchAsync(new CountrySearchCondition
            {
                PageNo         = pageIndex,
                RecordsPerPage = pageSize
            });

            PaginatedDto <CountryDto> countryPaginatedDto = _mapper.Map <PaginatedList <Country>, PaginatedDto <CountryDto> >(countries);

            return(countryPaginatedDto);
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> GetAll([FromQuery] PoolFilter filter, [FromQuery] int rowsPerPage = 20, [FromQuery] int pageNumber = 1)
        {
            string userEmail = User.FindFirst(ClaimTypes.Email).Value;
            User   user      = await userManager.FindByEmailAsync(userEmail);

            PaginatedElement <Pool> pools = poolService.Get(filter, rowsPerPage, pageNumber, user);

            PaginatedDto <PoolDto> dto = mapper.Map <PaginatedDto <PoolDto> >(pools);

            dto.NextPageUrl = HttpContext.GetNextPageUrl(pageNumber < dto.PageCount);

            return(Ok(dto));
        }
Ejemplo n.º 10
0
        //GET api/<controller>
        public PaginatedDto <GenreDto> GetAll()
        {
            PaginatedDto <GenreDto> result = _genreService.GetGenres(1, 1);

            return(result);
        }