Ejemplo n.º 1
0
        public ServiceResult SearchUsersReturnProfiles()
        {
            DataFilter     filter         = this.GetFilter(Request);
            ProfileManager profileManager = new ProfileManager(Globals.DBConnectionKey, this.GetAuthToken(Request));
            var            profiles       = profileManager.GetUserProfiles(CurrentUser.AccountUUID, ref filter);

            LocationManager locationManager = new LocationManager(Globals.DBConnectionKey, this.GetAuthToken(Request));
            UserManager     userManager     = new UserManager(Globals.DBConnectionKey, this.GetAuthToken(Request));

            _profileMemberManager = new ProfileMemberManager(Globals.DBConnectionKey, this.GetAuthToken(Request));
            profiles = profiles.Select(s => new
            {
                Name           = s.Name,
                UUID           = s.UUID,
                UUIDType       = s.UUIDType,
                Image          = s.Image,
                Active         = s.Active,
                Description    = s.Description,
                Members        = string.IsNullOrWhiteSpace(s.MembersCache) ? _profileMemberManager.GetProfileMembers(s.UUID, s.AccountUUID, ref filter) : JsonConvert.DeserializeObject <List <ProfileMember> >(s.MembersCache),
                User           = string.IsNullOrWhiteSpace(s.UserCache) ? userManager.Get(s.UserUUID) : JsonConvert.DeserializeObject <User>(s.UserCache),
                LocationDetail = string.IsNullOrWhiteSpace(s.LocationDetailCache) ? locationManager.Get(s.LocationUUID) : JsonConvert.DeserializeObject <Location>(s.LocationDetailCache),
            }).Cast <dynamic>();
            return(ServiceResponse.OK("", profiles, filter.TotalRecordCount));
        }
Ejemplo n.º 2
0
        [System.Web.Http.Route("api/Profiles")] // was AllProfiles
        public ServiceResult GetAllUserProfiles()
        {
            ProfileManager  profileManager  = new ProfileManager(Globals.DBConnectionKey, this.GetAuthToken(Request));
            UserManager     userManager     = new UserManager(Globals.DBConnectionKey, this.GetAuthToken(Request));
            LocationManager locationManager = new LocationManager(Globals.DBConnectionKey, this.GetAuthToken(Request));

            _profileMemberManager = new ProfileMemberManager(Globals.DBConnectionKey, this.GetAuthToken(Request));

            List <Profile> tmp = new List <Profile>();

            DataFilter filter = this.GetFilter(Request);

            if (CurrentUser == null) //not logged in.
            {
                tmp = profileManager.GetPublicProfiles(ref filter);
            }
            else
            {
                tmp = profileManager.GetAllProfiles(ref filter);
            }

            if (tmp == null)
            {
                return(ServiceResponse.OK("", new List <Profile>()));
            }

            List <dynamic> profiles = tmp.Cast <dynamic>().ToList(); //profileManager.GetAllProfiles().Cast<dynamic>().ToList();

            profiles = profiles.Filter(ref filter);

            var defaultFilter = new DataFilter();

            // todo add profile Members? or rename profileLogs to profileMembers? so you can map multiple users to one profile
            // if profileLogs remember to sort by sortOrder
            _profileMemberManager = new ProfileMemberManager(Globals.DBConnectionKey, this.GetAuthToken(Request));
            profiles = profiles.Select(s => new
            {
                Name        = s.Name,
                UUID        = s.UUID,
                AccountUUID = s.AccountUUID,
                UUIDType    = s.UUIDType,
                Image       = s.Image,
                NSFW        = s.NSFW,
                // Email = s.Email,
                Active      = s.Active,
                Description = s.Description,
                Members     = string.IsNullOrWhiteSpace(s.MembersCache) ?
                              _profileMemberManager.GetProfileMembers(s.UUID, s.AccountUUID, ref filter) :
                              JsonConvert.DeserializeObject <List <ProfileMember> >(s.MembersCache),
                User = string.IsNullOrWhiteSpace(s.UserCache) ?
                       ConvertResult(userManager.Get(s.UserUUID)) :
                       JsonConvert.DeserializeObject <User>(s.UserCache),
                LocationDetail = string.IsNullOrWhiteSpace(s.LocationDetailCache) ?
                                 ConvertLocationResult(locationManager.Get(s.LocationUUID)) :
                                 JsonConvert.DeserializeObject <Location>(s.LocationDetailCache),

                //  this.selectedProfile.LocationUUID = data.UUID;
                //this.selectedProfile.LocationType = data.LocationType;
                //single,married,ply, + genders by age? so ply-mfmfm
                // Profile.cs todo add to profileLogs/Members

                //Location { get; set; }
                //LocationType { get; set; }
                //Theme { get; set; }
                //View { get; set; }
                //UserUUID { get; set; }
                //
                // Node.cs
                //Status = string.Empty;
                //AccountUUID = string.Empty;
                //Deleted = false;
                //Private = true;
                //SortOrder = 0;
                //CreatedBy = string.Empty;
                //DateCreated = DateTime.MinValue;
                //RoleWeight = RoleFlags.MemberRoleWeights.Member;
                //RoleOperation = ">=";
                //Image = "";
            }).Cast <dynamic>().ToList();

            return(ServiceResponse.OK("", profiles, filter.TotalRecordCount));
        }