protected void btnPost_Click(object sender, EventArgs e) { try { var newPost = new BLL.Post(); newPost.Content = activity.Text; newPost.DateTime = DateTime.Now; newPost.UserId = currentUser.Id; newPost.CircleId = DropDownList1.SelectedValue; newPost.Image = GeneralHelpers.UploadFile(FileUpload1); PostDAO.AddPost(newPost); rptUserPosts.DataSource = PostDAO.GetPostsByCircle("gym"); rptUserPosts.DataBind(); UserCircleDAO.ChangeUserCirclePoints( userId: currentUser.Id, circleName: newPost.CircleId, points: 30, source: "creating a new post", addNotification: true ); } catch (DbEntityValidationException ex) { var err = ex.EntityValidationErrors.FirstOrDefault().ValidationErrors.FirstOrDefault().ErrorMessage; } }
protected void Page_Load(object sender, EventArgs e) { RedirectValidator.isUser(); currentUser = (BLL.User)Session["currentUser"]; var circlesname = UserCircleDAO.GetAllUserCircles(currentUser.Id); if (!IsPostBack) { DropDownList1.DataSource = circlesname; DropDownList1.DataTextField = "CircleId"; DropDownList1.DataValueField = "CircleId"; DropDownList1.DataBind(); DropDownList2.DataSource = circlesname; DropDownList2.DataTextField = "CircleId"; DropDownList2.DataValueField = "CircleId"; DropDownList2.DataBind(); } var notfollow = UserDAO.GetNewUser(currentUser.Id); Repeater1.DataSource = notfollow; Repeater1.DataBind(); this.Title = "Home"; //CircleDAO.AddCircle("gym"); refreshGv(); }
public static void isUser(bool isAddingUserCircles = false) { User currentUser = (User)HttpContext.Current.Session["currentUser"]; if (currentUser == null) { HttpContext.Current.Response.Redirect("/Auth/Login.aspx"); } else { List <UserCircle> existingUserCircle = UserCircleDAO.GetAllUserCircles(currentUser.Id); if (existingUserCircle.Count.Equals(0) && !isAddingUserCircles) { string[] someArr = HttpContext.Current.Request.Url.LocalPath.Split('/'); // eg: /Profile/User.aspx -> [Profile, User.aspx] System.Diagnostics.Debug.WriteLine("Redirect:" + someArr[someArr.Length - 1]); if (!someArr[someArr.Length - 1].Equals("User.aspx")) { HttpContext.Current.Response.Redirect("/Profile/User.aspx?username="******"&addingCircles=true"); } } else if (!existingUserCircle.Count.Equals(0) && isAddingUserCircles) { HttpContext.Current.Response.Redirect("/Profile/User.aspx?username=" + currentUser.Username.Trim()); } } }
protected void rptUserPosts_ItemCommand(object source, RepeaterCommandEventArgs e) { Repeater repeater = (e.Item.FindControl("rptComment") as Repeater); if (e.CommandName == "Comment") { TextBox comment = (e.Item.FindControl("hello") as TextBox); var comt = comment.Text; var newComment = new BLL.Comment(); newComment.UserId = currentUser.Id; newComment.PostId = Convert.ToInt32(e.CommandArgument); newComment.comment_date = DateTime.Now; newComment.comment_text = comment.Text; CommentDAO.AddComment(newComment); comment.Text = String.Empty; repeater.DataSource = CommentDAO.GetCommentByPost(Convert.ToInt32(e.CommandArgument)); repeater.DataBind(); } if (e.CommandName == "Report") { RadioButtonList report = (e.Item.FindControl("RadioButtonList1") as RadioButtonList); var userpostindex = e.Item.ItemIndex; var rpt = report.SelectedValue; List <UserPost> userposts = new List <UserPost>(); UserPost selecteduserpost = ((List <UserPost>)rptUserPosts.DataSource)[userpostindex]; var newReport = new BLL.ReportedPost(); newReport.postId = selecteduserpost.Post.Id; newReport.reason = rpt; newReport.dateCreated = DateTime.Now; newReport.reporterUserId = currentUser.Id; ReportedPostDAO.AddReport(newReport); } if (e.CommandName == "Delete") { var deleteId = Convert.ToInt32(e.CommandArgument); var userpostindex = e.Item.ItemIndex; UserPost selecteduserpost = ((List <UserPost>)rptUserPosts.DataSource)[userpostindex]; if (currentUser.Id == selecteduserpost.User.Id) { CommentDAO.DeleteCommentByPostId(selecteduserpost.Post.Id); ReportedPostDAO.DeleteReportedPostByPostId(selecteduserpost.Post.Id); PostDAO.DeletePost(deleteId); refreshGv(); UserCircleDAO.ChangeUserCirclePoints( userId: currentUser.Id, circleName: selecteduserpost.Post.CircleId, points: -30, source: "removing a post", addNotification: true ); } } }
protected void btSubmit_Click(object sender, EventArgs e) { signedOutErrorContainer.Visible = false; Page.Validate(); if (!existingUserCircleList.Concat(addUserCircleList).Any()) { GeneralHelpers.AddValidationError(Page, "addUserCirclesGroup", "No circles have been added"); } if (!Page.IsValid) { signedOutErrorContainer.Visible = true; lbErrorMsg.Text = GeneralHelpers.GetFirstValidationError(Page.Validators, "addUserCirclesGroup"); } else { foreach (UserCircle userCircle in removeUserCircleList) { UserCircleDAO.ChangeUserCirclePoints( userId: userCircle.UserId, circleName: userCircle.CircleId, points: -50, source: "Removing the circle", addNotification: true ); UserCircleDAO.RemoveUserCircle(userCircle.Id); } foreach (UserCircle userCircle in addUserCircleList) { UserCircle addedUserCircle = UserCircleDAO.AddUserCircle(userCircle); UserCircleDAO.ChangeUserCirclePoints( userId: addedUserCircle.UserId, circleName: addedUserCircle.CircleId, points: 50, source: "Joining the circle", addNotification: true ); } Response.Redirect("/Redirect.aspx"); } }
public void refreshGv() { List <UserPost> userposts = new List <UserPost>(); List <BLL.UserCircle> userCircles = UserCircleDAO.GetAllUserCircles(currentUser.Id); foreach (BLL.UserCircle circle in userCircles) { List <UserPost> posts = PostDAO.GetPostsByCircle(circle.CircleId); foreach (UserPost post in posts) { userposts.Add(post); } } rptUserPosts.DataSource = userposts; rptUserPosts.DataBind(); }
protected void GridViewFollow_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { var data = e.Row.DataItem; BLL.User userpost = data as BLL.User; var circlesname = UserCircleDAO.GetAllUserCircles(userpost.Id); DropDownList DropDownList1 = (e.Row.FindControl("DropDownList1") as DropDownList); DropDownList1.DataSource = circlesname; DropDownList1.DataTextField = "CircleId"; DropDownList1.DataValueField = "CircleId"; DropDownList1.DataBind(); Button followButton = (e.Row.FindControl("peopleNearbyFollowBtn") as Button); followButton.Attributes["followingid"] = userpost.Id.ToString(); followButton.Attributes["followerid"] = currentUser.Id.ToString(); } }
protected void Page_Load(object sender, EventArgs e) { if (String.IsNullOrEmpty(Request.QueryString["addingCircles"])) { RedirectValidator.isUser(isAddingUserCircles: false); } else { addCirclesCloseButton.Visible = false; RedirectValidator.isUser(isAddingUserCircles: true); } currentUser = (BLL.User)Session["currentUser"]; requestedUser = GetUserByIdentifier(Request.QueryString["username"]); if (requestedUser == null) { requestedUser = currentUser; } Event retrieveEventData = new Event(); List <Event> createdEventDataList = new List <Event>(); if (!Page.IsPostBack) { existingUserCircleList = UserCircleDAO.GetAllUserCircles(requestedUser.Id); foreach (UserCircle userCircle in existingUserCircleList) { var userDetailsForCircle = UserCircleDAO.GetCircleFollowerDetails(userCircle.CircleId); circleFollowerDetailList.Add(userDetailsForCircle); } rptUpdateCircles.DataSource = existingUserCircleList; rptUpdateCircles.DataBind(); rptUserCircles.DataSource = existingUserCircleList; rptUserCircles.DataBind(); rptCircleFollowerLinks.DataSource = existingUserCircleList; rptCircleFollowerLinks.DataBind(); rptUserFollowing.DataSource = FollowDAO.GetAllFollowingUsers(requestedUser.Id); rptUserFollowing.DataBind(); createdEventDataList = retrieveEventData.GetAllEventCreatedByUser(currentUser.Id); rpViewEventPageCreated.DataSource = createdEventDataList; rpViewEventPageCreated.DataBind(); bindExisitingCircles(); updateCirclesModal(); initializeNearbyUserMap(); } GMap.OverlayClick += new EventHandler <OverlayEventArgs>(MarkerClick); Title = requestedUser.Username + " - MyCircles"; ProfilePicImage.ImageUrl = requestedUser.ProfileImage; lbName.Text = requestedUser.Name; lbUsername.Text = "@" + requestedUser.Username; lbBio.InnerText = requestedUser.Bio; lbCity.InnerText = requestedUser.City; if (requestedUser.Id == currentUser.Id) { btMessage.Visible = false; } else { var sCoord = new GeoCoordinate(Double.Parse(currentUser.Latitude.ToString()), Double.Parse(currentUser.Longitude.ToString())); var eCoord = new GeoCoordinate(Double.Parse(requestedUser.Latitude.ToString()), Double.Parse(requestedUser.Longitude.ToString())); lbDistance.InnerText = (sCoord.GetDistanceTo(eCoord) / 1000).ToString("0.0") + " km away"; btEditProfile.Visible = false; btMessage.Visible = true; followWarning.InnerText = requestedUser.Name + " has not followed anyone yet"; } if (String.IsNullOrEmpty(requestedUser.Bio)) { lbBio.Visible = false; } else { lbBio.Visible = true; } if (rptUserFollowing.Items.Count > 0) { followWarning.Visible = false; } else { followWarning.Visible = true; } }
protected void submitButt_Click(object sender, EventArgs e) { Event newEventData = new Event(); EventSchedule eventSchedule = new EventSchedule(); currentUser = (BLL.User)Session["currentUser"]; signedOutErrorContainer.Visible = false; if (String.IsNullOrEmpty(eventTitleTB.Text)) { GeneralHelpers.AddValidationError(Page, "addEvent", "Event Title not filled up under basic info!"); } if (String.IsNullOrEmpty(eventDescriptionTB.Text)) { GeneralHelpers.AddValidationError(Page, "addEvent", "Event Title not filled up under basic info!"); } if (String.IsNullOrEmpty(CategoryDropDownList.Text)) { GeneralHelpers.AddValidationError(Page, "addEvent", "Category not selected!"); } if (String.IsNullOrEmpty(organizerTB.Text)) { GeneralHelpers.AddValidationError(Page, "addEvent", "Orgainzer not filled up under basic info"); } if (LocationDLL.Text == "Venue") { if (String.IsNullOrEmpty(LocationTB.Text)) { GeneralHelpers.AddValidationError(Page, "addEvent", "Venue place not filled up under Location"); } } else { if (String.IsNullOrEmpty(LocationDLL.Text)) { GeneralHelpers.AddValidationError(Page, "addEvent", "Don't itchy hand delete the values from f12"); } } if (String.IsNullOrEmpty(startDateTB.Text)) { GeneralHelpers.AddValidationError(Page, "addEvent", "Start Date not filled up under Date And Time"); } if (String.IsNullOrEmpty(endDateTB.Text)) { GeneralHelpers.AddValidationError(Page, "addEvent", "End Date nor filled up under Date And Time"); } if (String.IsNullOrEmpty(startTimeDLL.Text)) { GeneralHelpers.AddValidationError(Page, "addEvent", "Start Date nor filled up under Date And Time"); } if (String.IsNullOrEmpty(endTimeDLL.Text)) { GeneralHelpers.AddValidationError(Page, "addEvent", "Start Date nor filled up under Date And Time"); } DateTime startDate; DateTime endDate; DateTime.TryParse(startDateTB.Text, out startDate); DateTime.TryParse(endDateTB.Text, out endDate); string startTime = startTimeDLL.Text; string endTime = endTimeDLL.Text; string startTimeHour = startTime.Substring(0, 2); string startTimeMinutes = startTime.Substring(2, 2); string endTimeHour = endTime.Substring(0, 2); string endTimeMinutes = endTime.Substring(2, 2); if (startDate > endDate) { GeneralHelpers.AddValidationError(Page, "addEvent", "why start date later than end date?"); } else { if (startDate == endDate) { if (Int32.Parse(startTimeHour) > Int32.Parse(endTimeHour)) { GeneralHelpers.AddValidationError(Page, "addEvent", "Start Time cannot be Later than End Time Since Date is the same"); } } } if (entryFeeStatusDDL.Text == "Not Free") { if (String.IsNullOrEmpty(entryFeeTB.Text)) { GeneralHelpers.AddValidationError(Page, "addEvent", "Entry Fee not filled up under Details"); } } else { if (String.IsNullOrEmpty(entryFeeStatusDDL.Text)) { GeneralHelpers.AddValidationError(Page, "addEvent", "Don't itchy hand delete the values from f12"); } } if (maxTimeAPersonCanRegisterDLL.Text == "Limit") { if (String.IsNullOrEmpty(maxTimeAPersonCanRegisterTB.Text)) { GeneralHelpers.AddValidationError(Page, "addEvent", "Max Time A Person Can Register not filled up under Details"); } } else { if (String.IsNullOrEmpty(maxTimeAPersonCanRegisterDLL.Text)) { GeneralHelpers.AddValidationError(Page, "addEvent", "Don't itchy hand delete the values from f12"); } } if (maxSlotAvaliableDDL.Text == "Limit") { if (String.IsNullOrEmpty(maxSlotTB.Text)) { GeneralHelpers.AddValidationError(Page, "addEvent", "Max Time A Person Can Register not filled up under Details"); } } else { if (String.IsNullOrEmpty(maxSlotAvaliableDDL.Text)) { GeneralHelpers.AddValidationError(Page, "addEvent", "Don't itchy hand delete the values from f12"); } } if (!(imageUpload.HasFile && (imageUpload.PostedFile.ContentType == "image/jpeg" || imageUpload.PostedFile.ContentType == "image/jpeg" || imageUpload.PostedFile.ContentType == "image/png"))) { GeneralHelpers.AddValidationError(Page, "addEvent", "File empty or upload wrong format"); } if (!Page.IsValid) { signedOutErrorContainer.Visible = true; lbErrorMsg.Text = GeneralHelpers.GetFirstValidationError(Page.Validators); } else { newEventData.eventName = eventTitleTB.Text; newEventData.eventDescription = eventDescriptionTB.Text; newEventData.eventCategory = CategoryDropDownList.SelectedItem.Text; System.Diagnostics.Debug.WriteLine("hello world testing11" + CategoryDropDownList.SelectedItem.Text); System.Diagnostics.Debug.WriteLine("hello world testing12" + CategoryDropDownList.SelectedValue); System.Diagnostics.Debug.WriteLine("hello world testing13" + CategoryDropDownList.SelectedItem.Value); newEventData.eventHolderName = organizerTB.Text; newEventData.eventHolderId = currentUser.Id; if (LocationDLL.Text == "To Be Announced") { newEventData.eventLocation = LocationDLL.Text; } else { newEventData.eventLocation = LocationTB.Text; } newEventData.eventLocation = LocationTB.Text; newEventData.eventStartDate = startDateTB.Text; newEventData.eventEndDate = endDateTB.Text; newEventData.eventStartTime = startTimeDLL.Text; newEventData.eventEndTime = endTimeDLL.Text; newEventData.eventEntryFeesStatus = entryFeeStatusDDL.Text; var imagePath = GeneralHelpers.UploadFile(imageUpload); //System.Diagnostics.Debug.WriteLine("hello world testing",imagePath); newEventData.eventImage = imagePath; newEventData.eventStatus = "onGoing"; if (singleEventRadioButton.Checked) { newEventData.singleOrRecurring = "Single"; } if (entryFeeStatusDDL.Text == "Free") { newEventData.eventTicketCost = "$0.00"; } else { newEventData.eventTicketCost = "$" + entryFeeTB.Text; } if (maxTimeAPersonCanRegisterDLL.Text == "No Limit") { newEventData.maxTimeAPersonCanRegister = maxTimeAPersonCanRegisterDLL.Text; } else { newEventData.maxTimeAPersonCanRegister = maxTimeAPersonCanRegisterTB.Text; } if (maxSlotAvaliableDDL.Text == "No Limit") { newEventData.eventMaxSlot = maxSlotAvaliableDDL.Text; } else { newEventData.eventMaxSlot = maxSlotTB.Text; } if (LocationDLL.Text == "To Be Announced") { newEventData.eventLocation = "To Be Announced"; } else { newEventData.eventLocation = LocationTB.Text; } UserCircleDAO.ChangeUserCirclePoints(currentUser.Id, CategoryDropDownList.Text, 20, "Creating An Event", true); Event newCreatedEvt = newEventData.AddNewEvent(); Response.Redirect("EventSchedulePage.aspx?eventID=" + newCreatedEvt.eventId); } }