public async Task <ActionResult <IEnumerable <AlbumResource> > > GetAllAsync([FromQuery] PagingApiModel paging)
        {
            if (paging.Page == 0)
            {
                var msg = "Offset value must be positive";
                _logger.LogError(msg);
                return(BadRequest(new ErrorResource(msg)));
            }

            if (paging.PageSize == 0)
            {
                var msg = "Limit value must be positive";
                _logger.LogError(msg);
                return(BadRequest(new ErrorResource(msg)));
            }

            //try
            //{
            var albums = await _supervisor.GetAllAlbumAsync(paging);

            var resource = _mapper.Map <IEnumerable <Album>, IEnumerable <AlbumResource> >(albums);

            return(new ObjectResult(resource));
            //}
            //catch (Exception ex)
            //{
            //    _logger.LogError(ex.Message);
            //    return StatusCode(500, ex);
            //}
        }
示例#2
0
        public async Task <IEnumerable <Album> > GetAllAlbumAsync(PagingApiModel paging)
        {
            try
            {
                var albums = await _albumRepository.GetAllAsync(paging.Page, paging.PageSize);

                return(albums);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#3
0
        public async Task <IActionResult> Get([FromQuery] PagingApiModel paging)
        {
            var result = await this.usersRepository.GetUsers(new Paging(paging.Page, paging.PageSize));

            var apiResult = new PagingResultApiModel <UserApiModel>
            {
                Items = result.Items.Select(u => new UserApiModel {
                    Id = u.Id, Username = u.Username
                }),
                Paging = PageDetailsApiModel.FromDomain(result.Paging)
            };

            return(this.Ok(apiResult));
        }
        public async Task <ActionResult <IEnumerable <ArtistResource> > > GetAllAsync([FromQuery] PagingApiModel paging)
        {
            if (paging.Page == 0)
            {
                var msg = "Offset value must be positive";
                _logger.LogError(msg);
                return(BadRequest(new ErrorResource(msg)));
            }

            if (paging.PageSize == 0)
            {
                var msg = "Limit value must be positive";
                _logger.LogError(msg);
                return(BadRequest(new ErrorResource(msg)));
            }

            var artists = await _supervisor.GetAllArtistAsync(paging);

            var resource = _mapper.Map <IEnumerable <ArtistResource> >(artists);

            return(new ObjectResult(resource));
        }
示例#5
0
        public async Task <IActionResult> GetUsersInGroup(string clientId, string groupId, [FromQuery] PagingApiModel paging)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.HttpBadRequest());
            }

            var result = await this.clientUsersRepository.GetUsers(clientId, groupId, new Paging(paging.Page, paging.PageSize));

            var userApiModels = new PagingResultApiModel <UserApiModel>
            {
                Items  = result.Items.Select(u => UserApiModel.FromDomain(u)),
                Paging = PageDetailsApiModel.FromDomain(result.Paging)
            };

            return(this.Ok(userApiModels));
        }
示例#6
0
        public async Task <IActionResult> GetUsers(string username, string claimType, string claimValue, [FromQuery] PagingApiModel pagingApiModel)
        {
            if (!this.ModelState.IsValid)
            {
                return(new UnprocessableEntityResult());
            }

            var pagingResult =
                await this.usersRepository.QueryUsers(
                    username,
                    claimType,
                    claimValue,
                    new Paging(pagingApiModel.Page, pagingApiModel.PageSize));

            var result = new PagingResultApiModel <UserApiModel>
            {
                Paging = PageDetailsApiModel.FromDomain(pagingResult.Paging),
                Items  = pagingResult.Items.Select(u => UserApiModel.FromDomainModel(u))
            };

            return(this.Ok(result));
        }
示例#7
0
        public async Task <IEnumerable <Artist> > GetAllArtistAsync(PagingApiModel paging)
        {
            var artists = await _artistRepository.GetAllAsync(paging.Page, paging.PageSize);

            return(artists);
        }