public HttpResponseMessage GetUserCreditsPaginated([FromUri] PaginatedRequest model)
        {
            PaginatedItemsResponse <UserCredits> response = _CreditsService.GetTransactionsPaginated(model);


            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> GetData([FromQuery] PaginatedRequest request)
        {
            var query = Repository.GetKarma(request.Sort);
            var data  = PaginatedData <KarmaItem> .Create(query, request, entity => new KarmaItem(entity));

            var users = await GrillBotService.GetUsersSimpleInfoBatchAsync(data.Data.Select(o => o.UserID));

            var position = PaginationHelper.CountSkipValue(request) + 1;

            foreach (var item in data.Data)
            {
                item.User = users.Find(o => o.ID == item.UserID);

                if (item.User == null)
                {
                    item.User    = SimpleUserInfo.DefaultUser;
                    item.User.ID = item.UserID;
                }

                item.Position = position;
                position++;
            }

            data.Data = data.Data.ToList();
            return(Ok(data));
        }
        public async Task<PaginatedResponse<IEnumerable<FriendsInCategoryResponse>>> GetFriendsInCategory(PaginatedRequest<FriendsInCategoryRequest> request, SystemSession session)
        {
            var serviceRequest = new UserCategory
            {
                UserId = session.UserId.ToString(),
                UserCategoryTypeId = request.Data.CategoryId,
                InvertCatSerch = request.Data.InvertCategorySearch,
                PageIndex = request.PageIndex,
                PageSize = request.PageSize + 1
            };

            var data = await Task.Factory.StartNew(() => Client.UserService.getUserFriendsInCategory(serviceRequest, session.GetSession())).ConfigureAwait(false);
            var result = new PaginatedResponse<IEnumerable<FriendsInCategoryResponse>>
            {
                Page = data.Select(x => new FriendsInCategoryResponse
                {
                    UserId = x.UserId,
                    UserName = x.UserName,
                    Image = x.Picture,
                    FirstName = x.FirstName,
                    LastName = x.LastName,
                    Title = x.Title,
                    UserTypeId = (SystemUserType)x.UserTypeId,
                    Email = x.Email
                }).Take(request.PageSize),
                HasNextPage = data.Count > request.PageSize
            };

            return result;
        }
Ejemplo n.º 4
0
        public void GetAllAsync_GetAllBranchRestrictions_MultipleBranchRestrictionsAreRetrieved()
        {
            var paginatedRequest = new PaginatedRequest();
            var result           = _client.GetAllAsync(_defaultUser, _defaultRepository, paginatedRequest).Result;

            AssertHelper.AtLeastOnePropertyIsNotDefault <PaginatedResponse <BranchRestriction> >(result);
        }
Ejemplo n.º 5
0
        public IActionResult Hfeed([FromQuery] HomeFeedRequest model)
        {
            HomeFeedReturn ret;
            Claim          idClaim = User.FindFirst("sub");

            PaginatedRequest feedReq = new PaginatedRequest()
            {
                Order     = model.ActivityOrder,
                PageIndex = model.ActivityPageIndex,
                PageSize  = model.ActivityPageSize
            };
            PaginatedRequest urecReq = new PaginatedRequest()
            {
                Order     = model.UserRecommendationOrder,
                PageIndex = model.UserRecommendationPageIndex,
                PageSize  = model.UserRecommendationPageSize
            };
            PaginatedRequest grecReq = new PaginatedRequest()
            {
                Order     = model.GroupRecommendationsOrder,
                PageIndex = model.GroupRecommendationsPageIndex,
                PageSize  = model.GroupRecommendationsPageSize
            };

            ret = _feedDataService.GetUserFeed(idClaim?.Value, feedReq, urecReq, grecReq);

            return(Ok(ret));
        }
        public async Task<PaginatedResponseExtended<IEnumerable<UserInformationBaseExtendedResponse>, int>> GetMutualFriends(PaginatedRequest<string> request, SystemSession session)
        {
            var serviceRequest = new MutualFriend
            {
                UserId = session.UserId,
                TargetType = "F",
                TargetUser = request.Data,
                PageIndex = request.PageIndex,
                PageSize = request.PageSize
            };

            var data = await Task.Factory.StartNew(() => Client.UserService.getMutualFriends(serviceRequest, session.GetSession())).ConfigureAwait(false);
            var result = new PaginatedResponseExtended<IEnumerable<UserInformationBaseExtendedResponse>, int>
            {
                Page = data.MutualFriends.Select(x => new UserInformationBaseExtendedResponse
                {
                    UserId = x.UserId,
                    UserName = x.UserName,
                    UserTypeId = (SystemUserType)x.UserTypeId,
                    FirstName = x.FirstName,
                    LastName = x.LastName,
                    Image = x.Picture,
                    Title = x.Title
                }),
                HasNextPage = data.HasNextPage,
                Information = data.Count
            };

            return result;
        }
        public async Task<PaginatedResponseExtended<IEnumerable<ViewerDetailResponse>, int>> GetProfileViewDetail(PaginatedRequest<GeneralKvPair<SystemProfileViewType, int>> request, SystemSession session)
        {
            var serviceRequest = new ProfileView
            {
                UserId = request.UserId,
                ViewType = (byte)request.Data.Id,
                TypeId = request.Data.Value,
                PageIndex = request.PageIndex,
                PageSize = request.PageSize
            };

            var response = await Task.Factory.StartNew(() => Client.UserService.profileViewDetail(serviceRequest, session.GetSession())).ConfigureAwait(false);
            var data = response.ProfileViews.Select(x => new ViewerDetailResponse
            {
                UserId = x.UserId,
                UserTypeId = (SystemUserType)x.UserTypeId,
                UserName = x.Username,
                FirstName = x.FirstName,
                LastName = x.LastName,
                Image = x.Picture,
                FriendshipStatus = (SystemFriendshipStatus)x.IsConnected,
                Observed = x.Observed,
                Title = x.Title,
                ViewedDate = Convert.ToDateTime(x.ViewDate)
            });
            var result = new PaginatedResponseExtended<IEnumerable<ViewerDetailResponse>, int>
            {
                Page = data,
                HasNextPage = response.HasNextPage,
                Information = response.ViewCount
            };
            return result;
        }
Ejemplo n.º 8
0
        public HomeFeedReturn GetUserFeed(string currUserId, PaginatedRequest feedReq, PaginatedRequest urecReq, PaginatedRequest grecReq)
        {
            HomeFeedReturn ret        = new HomeFeedReturn();
            bool           isLoggedIn = !string.IsNullOrEmpty(currUserId);

            if (!isLoggedIn)
            {
                ret.ErrorCode = "401";
                return(ret);
            }

            GetUserLikes(currUserId);

            string[] followingUserIds = currentUserFollowings.Where(p => p.Value == FollowState.Confirmed).Select(p => p.Key).ToArray();
            int      totalFollowing   = followingUserIds.Count();

            if (totalFollowing == 0)
            {
                return(ret);
            }

            ret.FriendActivities     = GetPaginatedUserActivityFeed(currUserId, followingUserIds, feedReq);
            ret.UserRecommeandations = GetPaginatedUserRecommendations(currUserId, followingUserIds, userGroupFollowIds, urecReq);
            ret.GroupRecommendations = GetPaginatedGroupRecommendations(currUserId, followingUserIds, userGroupFollowIds, grecReq);
            return(ret);
        }
        public async Task<PaginatedResponseExtended<IEnumerable<ViewSummaryResponse>, int>> GetProfileViewSummary(PaginatedRequest<int> request, SystemSession session)
        {
            var serviceRequest = new ProfileView
            {
                UserId = request.UserId,
                ViewType = request.Data,
                PageIndex = request.PageIndex,
                PageSize = request.PageSize
            };

            var response = await Task.Factory.StartNew(() => Client.UserService.profileViewSummary(serviceRequest, session.GetSession())).ConfigureAwait(false);
            var data = response.ProfileViews.Select(x => new ViewSummaryResponse
            {
                TypeId = x.TypeId,
                Name = x.FirstName,
                ViewCount = x.ViewersCount,
                NewViewCount = x.NewViews,
                LastViewed = Convert.ToDateTime(x.ViewDate)
            });
            var result = new PaginatedResponseExtended<IEnumerable<ViewSummaryResponse>, int>
            {
                Page = data,
                HasNextPage = response.HasNextPage,
                Information = response.ViewCount
            };
            return result;
        }
Ejemplo n.º 10
0
        public async Task <ICollection <Part> > GetLowStockAsync(PaginatedRequest request, IUserContext userContext)
        {
            var offsetRecords = (request.Page - 1) * request.Results;
            var sortDirection = request.Direction == SortDirection.Ascending ? "ASC" : "DESC";
            var query         =
                $@"SELECT * FROM Parts 
WHERE Quantity <= LowStockThreshold AND (@UserId IS NULL OR UserId = @UserId)
ORDER BY 
CASE WHEN @OrderBy IS NULL THEN PartId ELSE NULL END {sortDirection}, 
CASE WHEN @OrderBy = 'PartNumber' THEN PartNumber ELSE NULL END {sortDirection}, 
CASE WHEN @OrderBy = 'DigikeyPartNumber' THEN DigikeyPartNumber ELSE NULL END {sortDirection}, 
CASE WHEN @OrderBy = 'MouserPartNumber' THEN MouserPartNumber ELSE NULL END {sortDirection}, 
CASE WHEN @OrderBy = 'Cost' THEN Cost ELSE NULL END {sortDirection}, 
CASE WHEN @OrderBy = 'Quantity' THEN Quantity ELSE NULL END {sortDirection}, 
CASE WHEN @OrderBy = 'LowStockThreshold' THEN LowStockThreshold ELSE NULL END {sortDirection}, 
CASE WHEN @OrderBy = 'PartTypeId' THEN PartTypeId ELSE NULL END {sortDirection}, 
CASE WHEN @OrderBy = 'ProjectId' THEN ProjectId ELSE NULL END {sortDirection}, 
CASE WHEN @OrderBy = 'Location' THEN Location ELSE NULL END {sortDirection}, 
CASE WHEN @OrderBy = 'BinNumber' THEN BinNumber ELSE NULL END {sortDirection}, 
CASE WHEN @OrderBy = 'BinNumber2' THEN BinNumber2 ELSE NULL END {sortDirection}, 
CASE WHEN @OrderBy = 'Manufacturer' THEN Manufacturer ELSE NULL END {sortDirection}, 
CASE WHEN @OrderBy = 'ManufacturerPartNumber' THEN ManufacturerPartNumber ELSE NULL END {sortDirection}, 
CASE WHEN @OrderBy = 'DateCreatedUtc' THEN DateCreatedUtc ELSE NULL END {sortDirection} 
OFFSET {offsetRecords} ROWS FETCH NEXT {request.Results} ROWS ONLY;";
            var result = await SqlQueryAsync <Part>(query, new
            {
                Results   = request.Results,
                Page      = request.Page,
                OrderBy   = request.OrderBy,
                Direction = request.Direction,
                UserId    = userContext?.UserId
            });

            return(result);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Example implementation of List method: lists all entries of type <see cref="Todo"/>
        /// </summary>
        /// <returns></returns>
        public PaginatedResult <IEnumerable <Todo> > List(PaginatedRequest request)
        {
            var totalPages = 1;

            var totalItems = Repository.Count();

            var result = Repository.All();

            if (!string.IsNullOrEmpty(request.OrderBy))
            {
                result = result.OrderByMember(request.OrderBy, request.Reverse);
            }
            else
            {
                result = result.OrderByDescending(t => t.CreatedDate);
            }

            if (request.NumPerPage > 0)
            {
                totalPages = (result.Count() + request.NumPerPage - 1) / request.NumPerPage;

                result = result.Skip(request.NumPerPage * (request.CurrentPage - 1)).Take(request.NumPerPage);
            }

            return(new PaginatedResult <IEnumerable <Todo> >()
            {
                Data = result,
                TotalItems = totalItems,
                TotalPages = totalPages
            });
        }
Ejemplo n.º 12
0
        public async Task <ICollection <Project> > GetProjectsAsync(PaginatedRequest request, IUserContext userContext)
        {
            var offsetRecords = (request.Page - 1) * request.Results;
            var sortDirection = request.Direction == SortDirection.Ascending ? "ASC" : "DESC";
            var query         =
                $@"SELECT * FROM Projects 
WHERE (@UserId IS NULL OR UserId = @UserId) 
ORDER BY 
CASE WHEN @OrderBy IS NULL THEN ProjectId ELSE NULL END {sortDirection}, 
CASE WHEN @OrderBy = 'Name' THEN Name ELSE NULL END {sortDirection}, 
CASE WHEN @OrderBy = 'Description' THEN Description ELSE NULL END {sortDirection}, 
CASE WHEN @OrderBy = 'Location' THEN Location ELSE NULL END {sortDirection}, 
CASE WHEN @OrderBy = 'DateCreatedUtc' THEN DateCreatedUtc ELSE NULL END {sortDirection} 
OFFSET {offsetRecords} ROWS FETCH NEXT {request.Results} ROWS ONLY;";
            var result = await SqlQueryAsync <Project>(query, new
            {
                Results   = request.Results,
                Page      = request.Page,
                OrderBy   = request.OrderBy,
                Direction = request.Direction,
                UserId    = userContext?.UserId
            });

            return(result.ToList());
        }
Ejemplo n.º 13
0
        public PaginatedInterestCard GetUserInterests(string currUserId, PaginatedRequest req)
        {
            PaginatedInterestCard ret = new PaginatedInterestCard();

            userGroupFollowIds = _userLikesCacheService.GetUserFollowingGroupsIds(currUserId);
            if (userGroupFollowIds == null || userGroupFollowIds.Count() == 0)
            {
                userGroupFollowIds = _userLikesDataService.GetUserFollowingGroups(currUserId, 30);
                _userLikesCacheService.SetUserFollowingGroupsIds(currUserId, userGroupFollowIds, 20);
            }
            int total = userGroupFollowIds.Count();

            if (total < 1)
            {
                return(ret);
            }
            int[] paginatedIds = userGroupFollowIds.Skip((req.PageIndex - 1) * req.PageSize).Take(req.PageSize).ToArray();
            ret.Entities = _context.Set <Group>().AsNoTracking()
                           .Select(f => new { Entity = f, f.ProfileImage })
                           .Where(p => paginatedIds.Contains(p.Entity.Id))
                           .Select(p => new InterestCard()
            {
                AlphaColor             = p.Entity.ColorAlpha,
                UrlKey                 = p.Entity.UrlKey,
                Id                     = p.Entity.Id,
                Name                   = p.Entity.Name,
                IsCurrentUserFollowing = true,
                ProfileImage           = p.Entity.ProfileImage.SmallPath
            }).ToPaginatedList(req.PageIndex, req.PageSize, total);

            return(ret);
        }
Ejemplo n.º 14
0
        //Single Get for getting all data with queries/pagination
        public PaginatedItemsResponse <Job> GetAllJobsWithFilter(PaginatedRequest model)
        {
            List <Job> JobList = null;
            PaginatedItemsResponse <Job> response = null;


            DataProvider.ExecuteCmd(GetConnection, "dbo.Jobs_SelectAll"
                                    , inputParamMapper : delegate(SqlParameterCollection paramCollection)
            {
                paramCollection.AddWithValue("@CurrentPage", model.CurrentPage);
                paramCollection.AddWithValue("@ItemsPerPage", model.ItemsPerPage);
                paramCollection.AddWithValue("@Query", model.Query);
                paramCollection.AddWithValue("@QueryWebsiteId", model.QueryWebsiteId);
                paramCollection.AddWithValue("@QueryStatus", model.QueryStatus);
                paramCollection.AddWithValue("@QueryJobType", model.QueryJobType);
                paramCollection.AddWithValue("@QueryStartDate", model.QueryStartDate);
                paramCollection.AddWithValue("@QueryEndDate", model.QueryEndDate);
            }, map : delegate(IDataReader reader, short set)

            {
                if (set == 0)
                {
                    Job SingleJob     = new Job();
                    int startingIndex = 0;   //startingOrdinal

                    SingleJob.Id                  = reader.GetSafeInt32(startingIndex++);
                    SingleJob.UserId              = reader.GetSafeString(startingIndex++);
                    SingleJob.JobStatus           = reader.GetSafeEnum <JobStatus>(startingIndex++);
                    SingleJob.JobType             = reader.GetSafeEnum <JobsType>(startingIndex++);
                    SingleJob.Price               = reader.GetSafeDecimal(startingIndex++);
                    SingleJob.Phone               = reader.GetSafeString(startingIndex++);
                    SingleJob.JobRequest          = reader.GetSafeInt32(startingIndex++);
                    SingleJob.SpecialInstructions = reader.GetSafeString(startingIndex++);
                    SingleJob.Created             = reader.GetSafeDateTime(startingIndex++);
                    SingleJob.Modified            = reader.GetSafeDateTime(startingIndex++);
                    SingleJob.WebsiteId           = reader.GetSafeInt32(startingIndex++);

                    if (JobList == null)
                    {
                        JobList = new List <Job>();
                    }
                    JobList.Add(SingleJob);
                }
                else if (set == 1)

                {
                    response            = new PaginatedItemsResponse <Job>();
                    response.TotalItems = reader.GetSafeInt32(0);
                }
            }

                                    );

            response.Items        = JobList;
            response.CurrentPage  = model.CurrentPage;
            response.ItemsPerPage = model.ItemsPerPage;

            return(response);
        }
Ejemplo n.º 15
0
        public IActionResult Hfinterests([FromQuery] PaginatedRequest model)
        {
            PaginatedInterestCard ret;
            Claim idClaim = User.FindFirst("sub");

            ret = _feedDataService.GetUserInterests(idClaim?.Value, model);
            return(Ok(ret));
        }
Ejemplo n.º 16
0
        public Task <PaginatedResponse <Repository> > GetAllPublicAsync(PaginatedRequest paginatedRequest)
        {
            var parameters  = CreateDefaultPaginationParameters(paginatedRequest);
            var restRequest = new RestComplexRequest(Method.GET, null, parameters);
            var task        = MakeAsyncRequest <PaginatedResponse <Repository> >(string.Empty, restRequest);

            return(task);
        }
Ejemplo n.º 17
0
 private static IQueryable <T> Sort <T>(this IQueryable <T> query, PaginatedRequest pagedRequest)
 {
     if (!string.IsNullOrWhiteSpace(pagedRequest.ColumnNameForSorting))
     {
         query = query.OrderBy(pagedRequest.ColumnNameForSorting + " " + pagedRequest.SortDirection);
     }
     return(query);
 }
Ejemplo n.º 18
0
        protected Dictionary <string, string> CreateDefaultPaginationParameters(PaginatedRequest request)
        {
            var dictionary = new Dictionary <string, string>();

            dictionary.Add(request.Page.Name, request.Page.Value.ToString());
            dictionary.Add(request.PageLength.Name, request.PageLength.Value.ToString());
            return(dictionary);
        }
Ejemplo n.º 19
0
        public async Task <Result <string, OkraError> > RetrieveAuthAsPdfAsync(PaginatedRequest request)
        {
            var url = "products/auths";

            var response = await _okraApi.Post <RetrieveAuthAsPdfResponse, RetrieveAuthAsPdfRequest>(url,
                                                                                                     new RetrieveAuthAsPdfRequest { Limit = request.Limit, Page = request.Page });

            return(response.ToResult());
        }
Ejemplo n.º 20
0
        public PaginatedItemsResponse <UserCredits> GetTransactionsPaginated(PaginatedRequest model)
        {
            List <UserCredits> TransactionsList           = null;
            PaginatedItemsResponse <UserCredits> response = null;

            DataProvider.ExecuteCmd(GetConnection, "dbo.UserCredits_SelectAll"
                                    , inputParamMapper : delegate(SqlParameterCollection paramCollection)
            {
                paramCollection.AddWithValue("@CurrentPage", model.CurrentPage);
                paramCollection.AddWithValue("@ItemsPerPage", model.ItemsPerPage);
                paramCollection.AddWithValue("@Query", model.Query);
            }, map : delegate(IDataReader reader, short set)
            {
                if (set == 0)

                {
                    UserCredits data  = new UserCredits();
                    int startingIndex = 0;   //startingOrdinal

                    data.Id            = reader.GetSafeInt32(startingIndex++);
                    data.UserId        = reader.GetSafeString(startingIndex++);
                    data.Amount        = reader.GetSafeDecimal(startingIndex++);
                    data.TransactionId = reader.GetSafeInt32(startingIndex++);
                    data.JobId         = reader.GetSafeInt32(startingIndex++);
                    data.DateAdded     = reader.GetSafeDateTime(startingIndex++);

                    UserMini User = new UserMini();

                    User.FirstName = reader.GetSafeString(startingIndex++);
                    User.LastName  = reader.GetSafeString(startingIndex++);
                    User.Email     = reader.GetSafeString(startingIndex++);
                    User.Phone     = reader.GetSafeString(startingIndex++);
                    User.Url       = reader.GetSafeString(startingIndex++);

                    data.User = User;

                    if (TransactionsList == null)
                    {
                        TransactionsList = new List <UserCredits>();
                    }

                    TransactionsList.Add(data);
                }
                else if (set == 1)
                {
                    response = new PaginatedItemsResponse <UserCredits>();

                    response.TotalItems = reader.GetSafeInt32(0);
                }
            }

                                    );
            response.Items        = TransactionsList;
            response.CurrentPage  = model.CurrentPage;
            response.ItemsPerPage = model.ItemsPerPage;
            return(response);
        }
Ejemplo n.º 21
0
        public Task <PaginatedResponse <Repository> > GetForksAsync(string owner, string reposlug,
                                                                    PaginatedRequest paginatedRequest)
        {
            var segments    = CreateDefaultSegmentsDictionary(owner, reposlug);
            var parameters  = CreateDefaultPaginationParameters(paginatedRequest);
            var restRequest = new RestComplexRequest(Method.GET, segments, parameters);
            var task        = MakeAsyncRequest <PaginatedResponse <Repository> >(FORKS_REPOSITORY_RESOURCE, restRequest);

            return(task);
        }
        public Task <PaginatedResponse <Activity> > GetAllActivityAsync(string owner, string reposlug,
                                                                        PaginatedRequest paginatedRequest)
        {
            var segments   = CreateDefaultSegmentsDictionary(owner, reposlug);
            var parameters = CreateDefaultPaginationParameters(paginatedRequest);
            var request    = new RestComplexRequest(Method.GET, segments, parameters);
            var task       = MakeAsyncRequest <PaginatedResponse <Activity> >(ACTIVITY_PULL_REQUEST_RESOURCE, request);

            return(task);
        }
Ejemplo n.º 23
0
        public HttpResponseMessage GetAllJobsWithFilter([FromUri] PaginatedRequest model)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            PaginatedItemsResponse <Job> response = _JobsService.GetAllJobsWithFilter(model);

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
Ejemplo n.º 24
0
        public virtual async Task <WhereResult <RoleData> > Where(PaginatedRequest req, Func <Role, bool> predicate)
        {
            var count = await _context.RoleSet.CountAsync(u => predicate(u));

            var list = await _context.RoleSet.Where(predicate)
                       .Skip(req.CurrentPage * req.ItemPerPage)
                       .Take(req.ItemPerPage)
                       .Select(i => new RoleData(i)).AsQueryable().ToListAsync();

            return(new WhereResult <RoleData>(new PaginatedResult <RoleData>(req, totalItems: count, items: list)));
        }
        //get all competency users. this is used to populate the index page.
        //some dir-paginate calls in here that do not work yet.
        public PaginateItemsResponse <CompetencyUser> GetCompetencyUsers()
        {
            PaginatedRequest      model    = new PaginatedRequest();
            List <CompetencyUser> userList = null;
            PaginateItemsResponse <CompetencyUser> response = null;

            DataProvider.ExecuteCmd(GetConnection, "dbo.Competency_Users_SelectAll"
                                    , inputParamMapper : delegate(SqlParameterCollection paramCollection)
            {
                paramCollection.AddWithValue("@CurrentPage", model.CurrentPage);
                paramCollection.AddWithValue("@ItemsPerPage", model.ItemsPerPage);
                paramCollection.AddWithValue("@Query", model.Query);
            }, map : delegate(IDataReader reader, short set)
            {
                if (set == 0)
                {
                    CompetencyUser CompetencyUser = new CompetencyUser();
                    int startingIndex             = 0;

                    CompetencyUser.Id               = reader.GetSafeString(startingIndex++);
                    CompetencyUser.FirstName        = reader.GetSafeString(startingIndex++);
                    CompetencyUser.LastName         = reader.GetSafeString(startingIndex++);
                    CompetencyUser.CompetencyId     = reader.GetSafeInt32(startingIndex++);
                    CompetencyUser.CompetencyName   = reader.GetSafeString(startingIndex++);
                    CompetencyUser.Email            = reader.GetSafeString(startingIndex++);
                    CompetencyUser.AuthorizedBy     = reader.GetSafeString(startingIndex++);
                    CompetencyUser.CreatedDate      = reader.GetDateTime(startingIndex++);
                    CompetencyUser.Status           = reader.GetSafeString(startingIndex++);
                    CompetencyUser.ActivityType     = reader.GetSafeString(startingIndex++);
                    CompetencyUser.Notes            = reader.GetSafeString(startingIndex++);
                    CompetencyUser.Attachments      = reader.GetSafeString(startingIndex++);
                    CompetencyUser.competencyUserId = reader.GetSafeInt32(startingIndex++);


                    if (userList == null)
                    {
                        userList = new List <CompetencyUser>();
                    }
                    userList.Add(CompetencyUser);
                }
                else if (set == 1)
                {
                    response = new PaginateItemsResponse <CompetencyUser>();

                    response.TotalItems = reader.GetSafeInt32(0);
                }
            }

                                    );
            response.Items        = userList;
            response.CurrentPage  = model.CurrentPage;
            response.ItemsPerPage = model.ItemsPerPage;
            return(response);
        }
Ejemplo n.º 26
0
        public Task <PaginatedResponse <User> > GetFollowingAsync(string teamName, PaginatedRequest request)
        {
            var segments = new Dictionary <string, string>()
            {
                { TEAM_NAME_SEGMENT, teamName }
            };
            var restRequest = new RestComplexRequest(Method.GET, segments, null);
            var task        = MakeAsyncRequest <PaginatedResponse <User> >(TEAM_FOLLOWING_RESOURCE, restRequest);

            return(task);
        }
Ejemplo n.º 27
0
        public async Task <PaginatedResult <ApplicationUserModel> > GetUsersAsync(PaginatedRequest paginatedRequest)
        {
            var users = await _users.CreatePaginatedResultAsync <ApplicationUserModel>(paginatedRequest, _mapper);

            foreach (var appUserDTO in users.Items)
            {
                appUserDTO.RoleString = _personalInfoRepository.GetRoleName(appUserDTO.userRoleId);
            }

            return(users);
        }
Ejemplo n.º 28
0
        public Task <PaginatedResponse <Comment> > GetCommentsAsync(string owner, string repoSlug, string revision,
                                                                    PaginatedRequest paginatedRequest)
        {
            var segments = CreateDefaultSegmentsDictionary(owner, repoSlug);

            segments.Add(REVISION_SEGMENT, revision);
            var parameters  = CreateDefaultPaginationParameters(paginatedRequest);
            var restRequest = new RestComplexRequest(Method.GET, segments, parameters, null);
            var task        = MakeAsyncRequest <PaginatedResponse <Comment> >(SPECIFIED_COMMIT_COMMENTS_RESOURCE, restRequest);

            return(task);
        }
Ejemplo n.º 29
0
 public async Task <WhereResult <UserData> > Where(PaginatedRequest req, Func <User, bool> predicate)
 {
     try
     {
         return(await _query.Where(req, predicate));
     }
     catch (Exception ex)
     {
         //TODO Trace ex
         return(new WhereResult <UserData>(ex));
     }
 }
Ejemplo n.º 30
0
        public async Task <IActionResult> Get(PaginatedRequest request,
                                              CancellationToken cancellationToken)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var result = await _showsService.GetAllPaginatedAsync(request.Page, request.PageSize, cancellationToken);

            return(Ok(result));
        }
        public Task <PaginatedResponse <Comment> > GetCommentsAsync(string owner, string reposlug, long pullRequestId,
                                                                    PaginatedRequest paginatedRequest)
        {
            var segments = CreateDefaultSegmentsDictionary(owner, reposlug);

            segments.Add(PULL_REQUEST_ID_SEGMENT, pullRequestId.ToString());
            var parameters = CreateDefaultPaginationParameters(paginatedRequest);
            var request    = new RestComplexRequest(Method.GET, segments, parameters);
            var task       = MakeAsyncRequest <PaginatedResponse <Comment> >(COMMENTS_PULL_REQUEST_RESOURCE, request);

            return(task);
        }
Ejemplo n.º 32
0
        public Task <PaginatedResponse <User> > GetFollowingAsync(string user, PaginatedRequest request)
        {
            var segments = new Dictionary <string, string>()
            {
                { USERNAME_SEGMENT, user }
            };
            var parameters  = CreateDefaultPaginationParameters(request);
            var restRequest = new RestComplexRequest(Method.GET, segments, parameters);
            var task        = MakeAsyncRequest <PaginatedResponse <User> >(FOLLOWING_RESOURCE, restRequest);

            return(task);
        }
Ejemplo n.º 33
0
        public Task <PaginatedResponse <Repository> > GetAllAsync(string owner, PaginatedRequest paginatedRequest)
        {
            var segments = new Dictionary <string, string>()
            {
                { OWNER_SEGMENT, owner }
            };
            var parameters  = CreateDefaultPaginationParameters(paginatedRequest);
            var restRequest = new RestComplexRequest(Method.GET, segments, parameters);
            var task        = MakeAsyncRequest <PaginatedResponse <Repository> >(DEFAULT_OWNER_RESOURCE, restRequest);

            return(task);
        }
Ejemplo n.º 34
0
        public HttpResponseMessage GetCsv([FromUri] PaginatedRequest model)
        {
            string exportResponse = _AdminReportService.ExportCsv(model);

            HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);

            result.Content = new StringContent(exportResponse, Encoding.UTF8, "text/csv");
            result.Content.Headers.ContentType                 = new MediaTypeHeaderValue("application/octet-stream");
            result.Content.Headers.ContentDisposition          = new ContentDispositionHeaderValue("attachment"); //attachment will force download
            result.Content.Headers.ContentDisposition.FileName = "Reports.csv";

            return(result);
        }
        public async Task<PaginatedResponse<IEnumerable<WebFriendInformationResponse>>> GetWebFriends(PaginatedRequest<string> request, SystemSession session)
        {
            var serviceRequest = new WebOnlyFriend
            {
                UserId = session.UserId,
                TargetUser = request.Data,
                PageIndex = request.PageIndex,
                PageSize = request.PageSize
            };

            var data = await Task.Factory.StartNew(() => Client.UserService.getWebOnlyFriends(serviceRequest, session.GetSession())).ConfigureAwait(false);
            var result = new PaginatedResponse<IEnumerable<WebFriendInformationResponse>>
            {
                Page = data.WebOnlyFriends.Select(x => new WebFriendInformationResponse
                {
                    UserId = x.UserId,
                    UserName = x.Username,
                    FirstName = x.FirstName,
                    LastName = x.LastName,
                    StatusTypeId = (SystemUserAvailabilityCode)x.Status,
                    MobileNumber = x.PrimaryContactNum,
                    Title = x.Title,
                    UserTypeId = (SystemUserType)x.UserTypeId,
                    Image = x.Picture,
                    FriendshipStatus = (SystemFriendshipStatus)x.IsConnected,
                    MutualFriend = x.MutualFriends,
                    Address = x.Address,
                    Email = x.Email,
                    CanMessage = x.CanMessage,
                    AllowMessageForwarding = x.AllowMsgForwarding,
                    CanReceiveConnectionRequest = x.CanReceiveConnectionReq,
                    AllowAddingInChatGroup = x.AllowAddingChatGroup
                }),
                HasNextPage = data.HasNextPage,
            };

            return result;
        }
Ejemplo n.º 36
0
 public Task<PaginatedResponse<IEnumerable<WebFriendInformationResponse>>> GetWebFriends(PaginatedRequest<string> request, SystemSession session)
 {
     return _jUnitOfWork.Friend.GetWebFriends(request, session);
 }
Ejemplo n.º 37
0
 public Task<PaginatedResponseExtended<IEnumerable<UserInformationBaseExtendedResponse>, int>> GetMutualFriends(PaginatedRequest<string> request, SystemSession session)
 {
     return _jUnitOfWork.Friend.GetMutualFriends(request, session);
 }
        public async Task<HttpResponseMessage> GetSkill(PaginatedRequest<string> request)
        {
            if (!(request.Data.IsMatch(x => request.Data, RegexPattern.UserName, ActionContext, ModelState)
              && Validation.StringLength(request.Data, x => request.Data, 6, 30, ActionContext, ModelState))
              && !request.Data.IsMatch(x => request.Data, RegexPattern.Numeric, ActionContext, ModelState))
                return ActionContext.Response;

            var response = await _profilePersonalService.GetUserSkills(request, Request.GetSession()).ConfigureAwait(false);
            return Request.SystemResponse(SystemDbStatus.Selected, response);
        }
        public async Task<PaginatedResponse<IEnumerable<UserSkillResponse>>> GetUserSkills(PaginatedRequest<string> request, SystemSession session)
        {
            var serviceRequest = new Skill
            {
                UserIdOrName = session.UserName,
                ProfileUser = request.Data,
                Offset = request.PageIndex,
                PageSize = request.PageSize
            };

            var response = await Task.Factory.StartNew(() => Client.UserService.getSkillSummary(serviceRequest, session.GetSession())).ConfigureAwait(false);
            var data = response.Skills.Select(x => new UserSkillResponse { Name = x.SkillName, SkillTypeId = x.SkillTypeId, ThumbsCount = x.ThumbsCount, YourThumb = x.YourThumb, UsersString = x.Users }).ToList();
            var allUsers = response.Skills.Where(x => x.Users != null).SelectMany(x => x.Users.Split(',')).Distinct().ToList();

            if (allUsers.Any())
            {
                var users = await Task.Factory.StartNew(() => Client.UserService.getUsersInfo(string.Join(",", allUsers), session.GetSession())).ConfigureAwait(false);
                var usersInformation = users.Select(x => new UserInformationBaseExtendedResponse { UserId = x.UserId, UserName = x.UserName, UserTypeId = (SystemUserType)x.UserTypeId, Image = x.Picture, FirstName = x.FirstName, LastName = x.LastName, Title = x.Title }).ToList();
                foreach (var userSkillResponse in data.Where(userSkillResponse => !string.IsNullOrEmpty(userSkillResponse.UsersString)))
                {
                    var skillResponse = userSkillResponse;
                    userSkillResponse.Users = usersInformation.Where(x => skillResponse.UsersString.Split(',').ToList().ConvertAll(Convert.ToInt32).Contains(x.UserId));
                }
            }
            var result = new PaginatedResponse<IEnumerable<UserSkillResponse>>
            {
                Page = data,
                HasNextPage = response.HasNextPage
            };

            return result;
        }
 public Task<PaginatedResponse<IEnumerable<UserSkillResponse>>> GetUserSkills(PaginatedRequest<string> request, SystemSession session)
 {
     // return _unitOfWork.Profile.GetUserSkills(request);
     return _jUnitOfWork.ProfilePersonal.GetUserSkills(request, session);
 }
 public Task<PaginatedResponse<IEnumerable<ThumbsForSkillDetailResponse>>> GetThumbsForSkillDetail(PaginatedRequest<ThumbsForSkillDetailRequest> request, SystemSession session)
 {
     return _jUnitOfWork.ProfilePersonal.GetThumbsForSkillDetail(request.Data, request.PageIndex, request.PageSize, session);
 }
Ejemplo n.º 42
0
 public Task<PaginatedResponseExtended<IEnumerable<ViewerDetailResponse>, int>> GetProfileViewDetail(PaginatedRequest<GeneralKvPair<SystemProfileViewType, int>> request, SystemSession getSession)
 {
     // return _unitOfWork.Profile.GetProfileViewDetail(request);
     return _jUnitOfWork.Profile.GetProfileViewDetail(request, getSession);
 }
Ejemplo n.º 43
0
 public Task<PaginatedResponseExtended<IEnumerable<ViewSummaryResponse>, int>> GetProfileViewSummary(PaginatedRequest<int> request, SystemSession getSession)
 {
     //return _unitOfWork.Profile.GetProfileViewSummary(request);
     return _jUnitOfWork.Profile.GetProfileViewSummary(request, getSession);
 }
 public Task<PaginatedResponse<IEnumerable<FriendsInCategoryResponse>>> GetFriendsInCategory(PaginatedRequest<FriendsInCategoryRequest> request, SystemSession session)
 {
     return _jUnitOfWork.Category.GetFriendsInCategory(request, session);
 }