private void loadFriends()
        {
            DataTable dtFriends = new DataTable("Friends");

            dtFriends.Columns.Add("Username");
            dtFriends.Columns.Add("Name");
            dtFriends.Columns.Add("StatusText");

            string[] friendsUsernames = User.FetchMutuallyFriends(CurrentUserSession.Username);
            string statusText = String.Empty;
            string nameText = String.Empty;

            foreach (string username in friendsUsernames)
            {
                try
                {
                    User user = User.Load(username);

                    if (user.IsOnline())
                    {
                        statusText = Server.HtmlEncode(user.StatusText);
                        using (var db = new Model.AspNetDatingDataContext()){
                            nameText = Server.HtmlEncode(
                                CompiledQueries.FetchDisplayedName(db, CurrentUserSession.Username, user.Username));
                        }
                        dtFriends.Rows.Add(new object[] {username, nameText, statusText});
                    }
                }
                catch (NotFoundException)
                {
                    continue;
                }
            }

            if (dtFriends.Rows.Count > 0)
            {
                rptFriends.DataSource = dtFriends;
                rptFriends.DataBind();
                mvFriends.SetActiveView(vFriends);
            }
            else
            {
                mvFriends.SetActiveView(vNoFriends);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Fetches community photo approval by specified parameters.
        /// It returns an empty array if there are no community photo approval in DB by specified arguments.
        /// If these arguments are null it returns all community photo approval from DB.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="photoID">The photo ID.</param>
        /// <param name="username">The username.</param>
        /// <param name="fromDate">From date.</param>
        /// <param name="toDate">To date.</param>
        /// <param name="sortColumn">The sort column.</param>
        /// <returns></returns>
        private static CommunityPhotoApproval[] Fetch(int? id, int? photoID, string username,
            DateTime? fromDate, DateTime? toDate, eSortColumn sortColumn)
        {
            using (var db = new Model.AspNetDatingDataContext())
            {
                var photoApprovals = from cpa in db.CommunityPhotoApprovals
                                     where (!id.HasValue || id == cpa.cpa_id)
                                           && (!photoID.HasValue || photoID == cpa.p_id)
                                           && (username == null || username == cpa.u_username)
                                           && (!fromDate.HasValue || cpa.cpa_timestamp >= fromDate)
                                           && (!toDate.HasValue || cpa.cpa_timestamp <= toDate)
                                     select new CommunityPhotoApproval
                                                {
                                                    id = cpa.cpa_id,
                                                    username = cpa.u_username,
                                                    photoID = cpa.p_id,
                                                    approved = cpa.cpa_approved,
                                                    date = cpa.cpa_timestamp
                                                };
                switch (sortColumn)
                {
                    case eSortColumn.None:
                        break;
                    case eSortColumn.Username:
                        photoApprovals = photoApprovals.OrderBy(pa => pa.username);
                        break;
                    case eSortColumn.Date:
                        photoApprovals = photoApprovals.OrderByDescending(pa => pa.date);
                        break;
                    default:
                        break;
                }

                return photoApprovals.ToArray();
            }

            //using (SqlConnection conn = Config.DB.Open())
            //{
            //    SqlDataReader reader = SqlHelper.ExecuteReader(conn, "FetchCommunityPhotoApproval",
            //                                                   id, photoID, username, fromDate, toDate,
            //                                                   sortColumn);

            //    List<CommunityPhotoApproval> lGroupPost = new List<CommunityPhotoApproval>();

            //    while (reader.Read())
            //    {
            //        CommunityPhotoApproval communityPhotoApproval = new CommunityPhotoApproval();

            //        communityPhotoApproval.id = (int)reader["ID"];
            //        communityPhotoApproval.photoID = (int)reader["PhotoID"];
            //        communityPhotoApproval.username = (string)reader["Username"];
            //        communityPhotoApproval.date = (DateTime)reader["Date"];
            //        communityPhotoApproval.approved = (bool) reader["Approved"];

            //        lGroupPost.Add(communityPhotoApproval);
            //    }

            //    return lGroupPost.ToArray();
            //}
        }
Esempio n. 3
0
        private static BannerCode[] Fetch(int? id, ePosition? position, bool? getDefault, eSortColumn sortColumn)
        {
            string cacheKey = String.Format("BannerCode_Fetch_{0}_{1}_{2}_{3}", id, position, getDefault, sortColumn);

            if (HttpContext.Current != null && HttpContext.Current.Cache[cacheKey] != null)
            {
                return HttpContext.Current.Cache[cacheKey] as BannerCode[];
            }

            using (var db = new Model.AspNetDatingDataContext())
            {
                var bannerCodes = from bc in db.BannerCodes
                                  where (!id.HasValue || bc.bc_id == id)
                                        && (!position.HasValue || bc.bc_position == (int?) position)
                                        && (!getDefault.HasValue || bc.bc_target == null)
                                  select new BannerCode
                                             {
                                                 id = bc.bc_id,
                                                 position = (ePosition) bc.bc_position,
                                                 priority = bc.bc_priority,
                                                 target = bc.bc_target,
                                                 code = bc.bc_code
                                             };
                switch (sortColumn)
                {
                    case eSortColumn.None :
                        break;
                    case eSortColumn.Priority :
                        bannerCodes = bannerCodes.OrderByDescending(bc => bc.priority);
                        break;
                }

                if (HttpContext.Current != null)
                {
                    HttpContext.Current.Cache.Insert(cacheKey, bannerCodes.ToArray(), CacheDependencies.Get(), DateTime.Now.AddMinutes(30),
                        Cache.NoSlidingExpiration);
                }

                return bannerCodes.ToArray();
            }
        }
Esempio n. 4
0
        public static string[] FetchUsernamesByFacebookID(long[] facebookIDs)
        {
            using (var db = new Model.AspNetDatingDataContext())
            {
                var res = from u in db.Users
                          where (from id in facebookIDs select (long?)id).Contains(u.u_facebookid) &&
                                !u.u_deleted
                          select u.u_username;

                return res.ToArray();
            }
        }
Esempio n. 5
0
        public DateTime FetchFriendRequestTimeStamp(string username)
        {
            using (var db = new Model.AspNetDatingDataContext())
            {
                return CompiledQueries.FetchFriendshipRequestTimeStamp(db, this._username, username);

                //var res = from f in db.Friends
                //          where f.u_username == username && f.f_username == this.username
                //          select f.f_timestamp;

                //return res.FirstOrDefault();
            }
        }
Esempio n. 6
0
        public static string[] FetchUsernamesByMySpaceID(string[] mySpaceIDs)
        {
            using (var db = new Model.AspNetDatingDataContext())
            {
                var res = from u in db.Users
                          where (from id in mySpaceIDs select id).Contains(u.u_myspaceid) &&
                          !u.u_deleted
                          select u.u_username;

                return res.ToArray();
            }
        }
Esempio n. 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Request.Params["uid"] == null)
                {
                    Response.Redirect("~/Home.aspx");
                    return;
                }

                if (Config.Misc.EnableMobileVersion && Misc.IsMobileBrowser())
                {
                    Response.Redirect(UrlRewrite.CreateMobileShowUserUrl(Request.Params["uid"]));
                    return;
                }

                if (CurrentUserSession == null && Config.Users.RegistrationRequiredToBrowse)
                {
                    Response.Redirect("Login.aspx?back_url=" + Server.UrlEncode(Request.Url.AbsoluteUri));
                    return;
                }

                if (Config.Users.CompletedProfileRequiredToBrowseSearch &&
                    CurrentUserSession != null && !CurrentUserSession.HasProfile && !CurrentUserSession.IsAdmin())
                {
                    Response.Redirect("Profile.aspx?err=profnotcompl");
                    return;
                }

                if (Config.Users.PhotoRequiredToBrowseSearch &&
                    CurrentUserSession != null && !CurrentUserSession.HasPhotos && !CurrentUserSession.IsAdmin())
                {
                    Response.Redirect("Profile.aspx?err=nophoto");
                    return;
                }

                LoadStrings();

                try
                {
                    User user = User.Load(Request.Params["uid"]);

                    if (user.Deleted)
                    {
                        if (user.DeleteReason == null || user.DeleteReason.Trim().Length == 0)
                            Page.StatusPageMessage = "This user has been deleted!".Translate();
                        else
                            Page.StatusPageMessage =
                                String.Format(
                                    "This user has been deleted for the following reason:<br><br>{0}".Translate(),
                                    user.DeleteReason);
                        Response.Redirect("ShowStatus.aspx");
                        return;
                    }

                    ViewedUser = user;

                    // Save profile view
                    if (Page is ShowUserPage && CurrentUserSession != null &&
                        !CurrentUserSession.IsOptionEnabled(eUserOptions.DisableProfileViews))
                    {
                        User.SaveProfileView(
                            CurrentUserSession.Username, ViewedUser.Username);

                        User.AddScore(CurrentUserSession.Username,
                                      Config.UserScores.ViewingProfile, "ViewingProfile");
                        User.AddScore(ViewedUser.Username,
                                      Config.UserScores.ViewedProfile, "ViewedProfile");

                        if (Config.Users.NewEventNotification && CurrentUserSession.Username != ViewedUser.Username
                            && (ViewedUser.IsOnline() || User.IsUsingNotifier(ViewedUser.Username)))
                        {
                            var text = String.Format("User {0} is viewing your profile!".Translate(),
                                                     "<b>" + CurrentUserSession.Username + "</b>");
                            int imageID;
                            try
                            {
                                imageID = CurrentUserSession.GetPrimaryPhoto().Id;
                            }
                            catch (NotFoundException)
                            {
                                imageID = ImageHandler.GetPhotoIdByGender(CurrentUserSession.Gender);
                            }
                            var thumbnailUrl = ImageHandler.CreateImageUrl(imageID, 50, 50, false, true, true);
                            var notification = new GenericEventNotification
                            {
                                Recipient = ViewedUser.Username,
                                Sender = CurrentUserSession.Username,
                                Text = text,
                                ThumbnailUrl = thumbnailUrl,
                                RedirectUrl = UrlRewrite.CreateShowUserUrl(CurrentUserSession.Username)
                            };
                            RealtimeNotification.SendNotification(notification);
                        }
                    }

                    #region show/hide IM link

                    string reason;
                    if (Config.Misc.EnableIntegratedIM &&
                        CurrentUserSession != null &&
                        !CurrentUserSession.StealthMode &&
                        ViewedUser.IsOnline() &&
                        CurrentUserSession.Username != ViewedUser.Username &&
                        User.CanSendMessage(CurrentUserSession, ViewedUser, out reason) &&
                        !Classes.User.IsUserBlocked(ViewedUser.Username, CurrentUserSession.Username))
                    {
                        pnlInstantMessenger.Visible = true;

                        var permissionCheckResult = CurrentUserSession.CanIM();

                        if (permissionCheckResult == PermissionCheckResult.No)
                            pnlInstantMessenger.Visible = false;
                        else
                        {
                            string root = HttpRuntime.AppDomainAppVirtualPath.TrimEnd('/');
                            var sectionUnlocked = UnlockedSection.IsSectionUnlocked(CurrentUserSession.Username, ViewedUser.Username, UnlockedSection.SectionType.IM, null);
                            if (permissionCheckResult == PermissionCheckResult.Yes || sectionUnlocked)
                            {
                                var timestamp = DateTime.Now.ToFileTimeUtc().ToString();
                                var hash = Misc.CalculateChatAuthHash(CurrentUserSession.Username, ViewedUser.Username, timestamp);
                                lnkInstantMessenger.HRef = "#";
                                lnkInstantMessenger.Attributes.Add("onclick",
                                                                   String.Format(
                                                                       "window.open('{0}/MessengerWindow.aspx?init=1&id={1}&target={2}&timestamp={3}&hash={4}', 'ajaxim_{1}_{2}', 'width=650,height=500,resizable=1,menubar=0,status=0,toolbar=0'); return false;",
                                                                       Config.Urls.ChatHome,
                                                                       CurrentUserSession.Username,
                                                                       ViewedUser.Username,
                                                                       timestamp,
                                                                       hash));
                                lnkInstantMessenger.Target = "AjaxIM_" + ViewedUser.Username;
                            }
                            else if (permissionCheckResult == PermissionCheckResult.YesWithCredits)
                            {
                                string url = String.Format(
                                    "if (confirm('{4}')) window.open('{0}/LaunchIM.aspx?targetUsername={1}', 'ajaxim_{2}_{3}', 'width=650,height=500,resizable=1,menubar=0,status=0,toolbar=0'); return false;",
                                    root, strTargetUserID,
                                    Regex.Replace(strUserID, @"[^A-Za-z0-9]", "_"),
                                    Regex.Replace(strTargetUserID, @"[^A-Za-z0-9]", "_"),
                                    String.Format(Lang.Trans("Opening the chat session will subtract {0} credits from your balance."), CurrentUserSession.BillingPlanOptions.CanIM.Credits /*Config.Credits.CreditsForIM*/));

                                lnkInstantMessenger.Attributes.Add("onclick", url);
                                lnkInstantMessenger.Attributes.Add("href", "");
                            }
                            else if (permissionCheckResult == PermissionCheckResult.YesButMoreCreditsNeeded ||
                                    permissionCheckResult == PermissionCheckResult.YesButPlanUpgradeNeeded)
                            {
                                lnkInstantMessenger.Visible = false;
                                lnkInstantMessengerPay.Visible = true;
                            }
                        }
                    }
                    else pnlInstantMessenger.Visible = false;

                    #endregion

                    #region set "allow/disallow user to view your private photos" links

                    if (Config.Photos.EnablePrivatePhotos &&
                        CurrentUserSession != null &&
                        CurrentUserSession.HasPrivatePhotos())
                    {
                        if (CurrentUserSession.HasUserAccessToPrivatePhotos(user.Username))
                            pnlGrantAccessToPrivatePhotos.Visible = false;
                        else
                            pnlDenyAccessToPrivatePhotos.Visible = false;
                    }
                    else
                    {
                        pnlGrantAccessToPrivatePhotos.Visible = false;
                        pnlDenyAccessToPrivatePhotos.Visible = false;
                    }

                    #endregion

                    #region set "allow/disallow user to view your private video" links

                    if (
                        CurrentUserSession != null &&
                        (CurrentUserSession.HasPrivateVideo()
                         || CurrentUserSession.HasPrivateVideoUpload()))
                    {
                        if (CurrentUserSession.HasUserAccessToPrivateVideo(user.Username))
                            pnlGrantAccessToPrivateVideo.Visible = false;
                        else
                            pnlDenyAccessToPrivateVideo.Visible = false;
                    }
                    else
                    {
                        pnlGrantAccessToPrivateVideo.Visible = false;
                        pnlDenyAccessToPrivateVideo.Visible = false;
                    }

                    #endregion

                    #region set "allow/disallow user to view your private audio" links

                    if (Config.Misc.EnableAudioUpload && CurrentUserSession != null &&
                        CurrentUserSession.HasPrivateAudio())
                    {
                        if (CurrentUserSession.HasUserAccessToPrivateAudio(user.Username))
                            pnlGrantAccessToPrivateAudio.Visible = false;
                        else
                            pnlDenyAccessToPrivateAudio.Visible = false;
                    }
                    else
                    {
                        pnlGrantAccessToPrivateAudio.Visible = false;
                        pnlDenyAccessToPrivateAudio.Visible = false;
                    }

                    #endregion

                    #region activate/deactivate RealPerson Verification links

                    if (Config.Users.EnableRealPersonVerificationFunctionality &&
                        CurrentUserSession != null)
                    {

                        using (var db = new Model.AspNetDatingDataContext())
                        {
                            var verifiedByThisUser =
                                db.VerifiedUsers.Any(u => u.vu_verifiedby == CurrentUserSession.Username
                                                               && u.vu_verifieduser == ViewedUser.Username);

                            if (verifiedByThisUser || CurrentUserSession.IsUserVerified(user.Username))
                                pnlCertifyUserIsGenuine.Visible = false;
                            else
                                pnlRemoveVerifiedUserStatus.Visible = false;
                        }
                    }
                    else
                    {
                        pnlCertifyUserIsGenuine.Visible = false;
                        pnlRemoveVerifiedUserStatus.Visible = false;
                    }

                    #endregion

                    #region Set "block/unlblock user" links

                    if (CurrentUserSession != null)
                    {
                        if (CurrentUserSession.IsUserBlocked(ViewedUser.Username))
                            pnlBlockUser.Visible = false;
                        else
                            pnlUnblockUser.Visible = false;
                    }
                    else
                    {
                        pnlBlockUser.Visible = false;
                        pnlUnblockUser.Visible = false;
                    }

                    #endregion

                    #region Enable/Disable ViewBlog

                    pnlBlog.Visible = Config.Misc.EnableBlogs && Blog.HasPosts(ViewedUser.Username);

                    #endregion

                    #region Enable/Disable ViewEvents

                    pnlViewEvents.Visible = Config.Users.EnableUserEventsPage;

                    #endregion

                    #region Add report abuse option

                    if (Config.AbuseReports.UserCanReportProfileAbuse
                        && (CurrentUserSession != null && (CurrentUserSession.BillingPlanOptions.UserCanReportAbuse.Value
                        || CurrentUserSession.Level != null && CurrentUserSession.Level.Restrictions.UserCanReportAbuse)))
                    {
                        pnlReportAbuseLink.Visible = true;
                    }

                    #endregion

                    #region Show blog if param is supplied

                    // Left for compatibility with old links to blog posts
                    if (Request.Params["bpid"] != null && !(Page is ShowUserBlog))
                    {
                        try
                        {
                            int blogPostId = Convert.ToInt32(Request.Params["bpid"]);
                            Response.Redirect(UrlRewrite.CreateShowUserBlogUrl(ViewedUser.Username,
                                blogPostId));
                            return;
                        }
                        catch (ArgumentException)
                        {
                        }
                    }

                    #endregion

                    #region Set meta tags

                    Parser parse = delegate(string text)
                                       {
                                           string result = text
                                               .Replace("%%USERNAME%%", user.Username)
                                               .Replace("%%AGE%%", user.Age.ToString())
                                               .Replace("%%GENDER%%", Lang.Trans(user.Gender.ToString()))
                                               .Replace("%%COUNTRY%%", user.Country)
                                               .Replace("%%STATE%%", user.State)
                                               .Replace("%%ZIP%%", user.ZipCode)
                                               .Replace("%%CITY%%", user.City);

                                           var regex = new Regex(@"%%Q_(\d+)%%");
                                           Match match = regex.Match(result);
                                           while (match.Success)
                                           {
                                               foreach (Capture capture in match.Groups[1].Captures)
                                               {
                                                   int questionId;
                                                   if (!int.TryParse(capture.Value, out questionId)) continue;
                                                   try
                                                   {
                                                       ProfileAnswer answer =
                                                           ProfileAnswer.Fetch(user.Username, questionId);
                                                       result =
                                                           result.Replace(String.Format("%%Q_{0}%%", questionId),
                                                                          Server.HtmlEncode(answer.Value));
                                                   }
                                                   catch (NotFoundException)
                                                   {
                                                       continue;
                                                   }
                                               }
                                               match = match.NextMatch();
                                           }

                                           return result;
                                       };

                    Page.Header.Title = parse(Config.SEO.ShowUserTitleTemplate);

                    var metaDesc = new HtmlMeta
                                       {
                                           ID = "Description",
                                           Name = "description",
                                           Content = parse(Config.SEO.ShowUserMetaDescriptionTemplate)
                                       };
                    Page.Header.Controls.Add(metaDesc);

                    var metaKeywords = new HtmlMeta
                                           {
                                               ID = "Keywords",
                                               Name = "keywords",
                                               Content = parse(Config.SEO.ShowUserMetaKeywordsTemplate)
                                           };
                    Page.Header.Controls.Add(metaKeywords);

                    #endregion

                }
                catch (ThreadAbortException)
                {
                }
                catch (ArgumentException)
                {
                    Response.Redirect("~/Home.aspx");
                }
                catch (NotFoundException)
                {
                    Response.Redirect("~/Home.aspx");
                }
                catch (Exception err)
                {
                    Global.Logger.LogError(err);
                    Response.Redirect("~/Home.aspx");
                }

                #region Show/Hide links

                if (CurrentUserSession != null)
                {
                    if (Config.Users.EnableFavorites)
                    {
                        if (CurrentUserSession.IsUserInFavouriteList(ViewedUser.Username))
                        {
                            pnlRemoveFromFavourites.Visible = true;
                            pnlAddToFavourites.Visible = false;
                        }
                        else
                        {
                            pnlRemoveFromFavourites.Visible = false;
                            pnlAddToFavourites.Visible = true;
                        }
                    }
                    else
                    {
                        pnlRemoveFromFavourites.Visible = false;
                        pnlAddToFavourites.Visible = false;
                    }

                    if (Config.Users.EnableFriends)
                    {
                        if (CurrentUserSession.IsUserInFriendList(ViewedUser.Username))
                        {
                            pnlRemoveFromFriends.Visible = true;
                            pnlAddToFriends.Visible = false;
                            pnlViewMutualFriends.Visible = false;
                        }
                        else
                        {
                            pnlRemoveFromFriends.Visible = false;
                            pnlAddToFriends.Visible = true;
                        }
                    }
                    else
                    {
                        pnlAddToFriends.Visible = false;
                        pnlRemoveFromFriends.Visible = false;
                        pnlViewMutualFriends.Visible = false;
                    }
                }
                else
                {
                    pnlRemoveFromFavourites.Visible = false;
                    pnlAddToFavourites.Visible = false;
                    pnlAddToFriends.Visible = false;
                    pnlRemoveFromFriends.Visible = false;
                    pnlViewMutualFriends.Visible = false;
                }

                if (Page is ShowUserPage && Config.ThirdPartyServices.UseBingTranslate)
                {
                    divTranslate.Visible = true;
                }

                #endregion

                if (Page is ShowUserPage)
                    Master.SetSelectedLink(lnkViewProfile.ClientID);
                else if (Page is ShowUserPhotos)
                    Master.SetSelectedLink(lnkViewPhotos.ClientID);
                else if (Page is ShowUserBlog)
                    Master.SetSelectedLink(lnkViewBlog.ClientID);
                else if (Page is ReportUserAbuse)
                    Master.SetSelectedLink(lnkReportAbuse.ClientID);
                else if (Page is ShowUserEvents)
                    Master.SetSelectedLink(lnkViewEvents.ClientID);

                SetSimilarProfilesProperties();
            }

            #region Apply profile skin

            if (ViewedUser.ProfileSkin != null || Request.Params["skin"] != null)
            {
                var cssSkinCommon = new HtmlLink();
                cssSkinCommon.Attributes.Add("rel", "stylesheet");
                cssSkinCommon.Attributes.Add("type", "text/css");
                cssSkinCommon.Href = "Skins/common.css";
                Page.Header.Controls.Add(cssSkinCommon);

                var cssSkin = new HtmlLink();
                cssSkin.Attributes.Add("rel", "stylesheet");
                cssSkin.Attributes.Add("type", "text/css");
                cssSkin.Href = Request.Params["skin"] ?? ViewedUser.ProfileSkin;
                Page.Header.Controls.Add(cssSkin);
            }

            #endregion

            PrepareLinks();
        }
Esempio n. 8
0
        /// <summary>
        /// Loads comments
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="fromUsername">From username.</param>
        /// <param name="toUsername">To username.</param>
        /// <param name="approveFilter">if set to <c>true</c> [approve filter].</param>
        /// <param name="approved">if set to <c>true</c> [approved].</param>
        /// <param name="countLimit">The count limit.</param>
        /// <returns></returns>
        public static Comment[] Load(int id, string fromUsername, string toUsername, bool approveFilter,
                                     bool approved, int countLimit)
        {
            using (var db = new Model.AspNetDatingDataContext())
            {
                var comments = from c in db.Comments
                               where (id == -1 || id == c.c_id)
                                     && (fromUsername == null || fromUsername == c.c_from_username)
                                     && (toUsername == null || toUsername == c.c_to_username)
                                     && (!approveFilter || approved == c.c_approved)
                               orderby c.c_date_posted descending
                               select new Comment
                                          {
                                              id = c.c_id,
                                              fromUsername = c.c_from_username,
                                              toUsername = c.c_to_username,
                                              commentText = c.c_comment_text,
                                              datePosted = c.c_date_posted,
                                              approved = c.c_approved
                                          };

                if (countLimit > -1)
                    comments = comments.Take(countLimit);

                return comments.ToArray();
                
            }

            //List<Comment> lComments = new List<Comment>();

            //using (SqlConnection conn = Config.DB.Open())
            //{
            //    SqlDataReader reader = SqlHelper.ExecuteReader(conn, "FetchComments", id, fromUsername,
            //                                                   toUsername, approveFilter ? (object) approved : null);

            //    int count = 0;
            //    while (reader.Read())
            //    {
            //        Comment comment = new Comment();

            //        comment.id = (int) reader["Id"];
            //        comment.fromUsername = (string) reader["FromUsername"];
            //        comment.toUsername = (string) reader["ToUsername"];
            //        comment.commentText = (string) reader["CommentText"];
            //        comment.datePosted = (DateTime) reader["DatePosted"];
            //        comment.approved = (bool) reader["Approved"];

            //        lComments.Add(comment);
            //        if (++count >= countLimit && countLimit > -1) break;
            //    }
            //}

            //return lComments.ToArray();
        }
Esempio n. 9
0
        public DateTime FetchFriendRequestTimeStamp(string username)
        {
            using (var db = new Model.AspNetDatingDataContext())
            {
                var res = from f in db.Friends
                          where f.u_username == username && f.f_username == this.username
                          select f.f_timestamp;

                return res.FirstOrDefault();
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Fetches photo comments by specified arguments.
        /// It returns an empty array if there are no photo comments in DB by specified arguments.
        /// If these arguments are null it returns all photo comments from DB.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="photoID">The photo ID.</param>
        /// <param name="username">The username.</param>
        /// <param name="numberOfComments">The number of comments.</param>
        /// <returns></returns>
        private static PhotoComment[] Fetch(int? id, int? photoID, string username, int? numberOfComments)
        {
            using (var db = new Model.AspNetDatingDataContext())
            {
                var photoComments = from pc in db.PhotoComments
                                    where (!id.HasValue || id == pc.pc_id)
                                          && (!photoID.HasValue || photoID == pc.p_id)
                                          && (username == null || username == pc.u_username)
                                    orderby pc.pc_date descending
                                    select new PhotoComment
                                               {
                                                   id = pc.pc_id,
                                                   photoID = pc.p_id,
                                                   username = pc.u_username,
                                                   comment = pc.pc_comment,
                                                   date = pc.pc_date
                                               };
                if (numberOfComments.HasValue)
                    photoComments = photoComments.Take(numberOfComments.Value);

                return photoComments.ToArray();
            }

            //using (SqlConnection conn = Config.DB.Open())
            //{
            //    SqlDataReader reader =
            //        SqlHelper.ExecuteReader(conn, "FetchPhotoComments", id, photoID, username, numberOfComments);

            //    List <PhotoComment> lPhotoComments = new List<PhotoComment>();

            //    while (reader.Read())
            //    {
            //        PhotoComment photoComment = new PhotoComment();

            //        photoComment.id = (int) reader["ID"];
            //        photoComment.photoID = (int) reader["PhotoID"];
            //        photoComment.username = (string) reader["Username"];
            //        photoComment.comment = (string) reader["Comment"];
            //        photoComment.date = (DateTime) reader["Date"];

            //        lPhotoComments.Add(photoComment);
            //    }

            //    return lPhotoComments.ToArray();
            //}
        }