Example #1
0
        public async Task <Pagination <User> > ListAsync(int offset, int limit)
        {
            this._logger.LogDebug("Starting ListAsync");

            this._logger.LogDebug("Validating pagination parameters");

            if (limit - offset > 100)
            {
                this._validationService.Throw("Limit", "Too much items for pagination", limit, Validation.PaginationExceedsLimits);
            }

            this._logger.LogDebug("Retriving paginated list of users");

            var users = await _sqlService.ListAsync <User>(UserQuery.PAGINATE, new
            {
                Limit     = limit,
                CreatedBy = "Renato",
                Offset    = offset
            });

            foreach (var user in users)
            {
                user.Contacts = await this._contactService.ListAsync(user.UserId);
            }

            this._logger.LogDebug("Retriving the number of users registered by the authenticated user");

            var total = await _sqlService.CountAsync(UserQuery.TOTAL, new
            {
                CreatedBy = "Renato",
            });

            this._logger.LogDebug("Retriving the number of users registered by the authenticated user");

            var pagination = new Pagination <User>()
            {
                Offset = offset,
                Limit  = limit,
                Items  = users,
                Total  = total
            };

            this._logger.LogDebug("Ending ListAsync");

            return(pagination);
        }
Example #2
0
        public async Task <IEnumerable <Contact> > ListAsync(int idUsuario)
        {
            this._logger.LogDebug("Starting GetAsync");

            this._logger.LogDebug("Retriving the list of Contacts");

            var contacts = await _sqlService.ListAsync <Contact>(ContactQuery.LIST_BY_USERID, new
            {
                UserId = idUsuario
            });

            this._logger.LogDebug("Checking if has any contact");

            this._logger.LogDebug("Ending GetAsync");

            return(contacts);
        }