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 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"); } }
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); } }