protected void PostSubmitButton_Click(object sender, EventArgs e) { string postText = InputPost.Text; string tags = InputPostTag.Text; if (string.IsNullOrEmpty(tags)) { tags = "All"; } int userID = Convert.ToInt32(Session["UserId"]); int profileId = (from profile in dbContext.Profiles where profile.User_UserId == userID select profile.ProfileId) .First(); dbContext.Posts.InsertOnSubmit(new Post() { PostText = postText, PostDateTime = DateTime.Now, Likes = 0, Tags = tags, Profile_ProfileId = profileId }); dbContext.SubmitChanges(); Response.Redirect(Request.RawUrl); }
protected void UpdateButton_Click(object sender, EventArgs e) { //Debug.WriteLine("Before Find The Update Data"); var updateProfile = dbContext.Profiles.Single(p => p.User_UserId == userId); updateProfile.FirstName = InputFirstName.Text; updateProfile.LastName = InputLastName.Text; updateProfile.City = InputCity.Text; updateProfile.Institution = InputInstitution.Text; updateProfile.Education = InputEducation.Text; updateProfile.About = InputAbout.Text; updateProfile.FavTag = InputFavTag.Text; //Debug.WriteLine("Before Writing Data"); dbContext.SubmitChanges(); //Debug.WriteLine("After Writing Data"); Response.Redirect(Request.RawUrl); }
protected void Page_Load(object sender, EventArgs e) { int profileId = Convert.ToInt32(Request.QueryString["PID"]); int userId = Convert.ToInt32(Session["UserId"]); dbContext.Friends.InsertOnSubmit(new Friend() { Profile_FriendId = profileId, User_UserId = userId }); dbContext.SubmitChanges(); Response.Redirect("FriendsPage"); }
protected void RegisterButton_Click(object sender, EventArgs e) { string firstName = InputFirstName.Text; string lastName = InputLastName.Text; string city = InputCity.Text; string dob = InputDOB.Text; string username = InputUsername.Text; string email = InputEmail.Text; string password = InputPassword.Text; string confPassword = InputConfPassword.Text; if (password.Equals(confPassword)) { try { dbContext.InsertNewUser( username: username, email: email, passHash: PasswordHasher.Hash(password), firstName: firstName, lastName: lastName, birthDate: DateTime.Parse(dob).Date, city: city ); dbContext.SubmitChanges(); SuccessPanel.Visible = true; } catch (Exception exception) { WarningPanel.Visible = true; WaringLabel.Text = exception.Message; } } else { WarningPanel.Visible = true; WaringLabel.Text = "Password did not mathched!!"; } }