public static UserPayee GetUserPayeeById(string UserPayeeId) { UserPayee userPayee; string sql = "SELECT * FROM UserPayees WHERE UserPayeeId = @UserPayeeId"; using (SqlConnection con = new SqlConnection(GetConnectionString())) { using (SqlCommand cmd = new SqlCommand(sql, con)) { cmd.Parameters.AddWithValue("UserPayeeId", UserPayeeId); con.Open(); SqlDataReader dr = cmd.ExecuteReader(); dr.Read(); userPayee = new UserPayee(); userPayee.UserPayeeId = dr["UserPayeeId"].ToString(); userPayee.UserId = dr["UserId"].ToString(); userPayee.PayeeId = dr["PayeeId"].ToString(); userPayee.Nickname = dr["Nickname"].ToString(); userPayee.PayeeAccountNumber = dr["PayeeAccountNumber"].ToString(); dr.Close(); } } return(userPayee); }
protected void CreatePayment_Click(object sender, EventArgs e) { // Create Payment OnlineBillPay.Models.Payment newPayment = new OnlineBillPay.Models.Payment(); newPayment.PaymentId = System.Guid.NewGuid().ToString().ToUpper(); newPayment.UserPayeeId = hdnExistingUserPayeeId.Value; newPayment.FundingSourceId = ddlFundingSource.SelectedValue; newPayment.UserId = User.Identity.GetUserId(); newPayment.Amount = float.Parse(txtPaymentAmount.Text); newPayment.DateCreated = DateTime.Now; newPayment.Currency = txtCurrency.Text; newPayment.Status = "Pending"; // Store into DB PaymentDb.InsertPayment(newPayment); UserPayee payee = (UserPayee)Session["PaymentInProgress_payee"]; // Set Payment success notification message Session["Payment_confirmation_message"] = "Your payment to " + payee.Nickname + " for " + newPayment.Amount + "(" + newPayment.Currency + ") is " + newPayment.Status + ". Thank you!"; Session["Payment_confirmation_message_play_count"] = 0; // Dump the UserPayee in Session Session["PaymentInProgress_payee"] = null; // Redirect to Account Home Response.Redirect("/Account/Default"); }
protected void Page_Load(object sender, EventArgs e) { UserPayee payee = (UserPayee)Session["PaymentInProgress_payee"]; Debug.WriteLine(payee.Nickname); Debug.WriteLine(payee.UserPayeeId); Debug.WriteLine(payee.UserId); // Validate that the UserId coming from UserPayee matches the one authenticated, else redirect to /Account/Default if (payee.UserId != User.Identity.GetUserId()) { Response.StatusCode = 403; Response.Redirect("/Account/Default"); } // Fill in Fields about the UserPayee txtNickname.Text = payee.Nickname; txtAccountNumber.Text = payee.PayeeAccountNumber; hdnExistingUserPayeeId.Value = payee.UserPayeeId; foreach (var fundingSources in FundingSourceDb.GetFundingSources(User.Identity.GetUserId()).ToList()) { ddlFundingSource.Items.Add(new ListItem { Text = fundingSources.Nickname.ToString(), Value = fundingSources.FundingSourceId.ToString() }); } }
protected void CreatePayee_Click(object sender, EventArgs e) { // Check to see if Payee exists Payee newPayee = new Payee(); // If payee not exists, create new payee if (String.IsNullOrEmpty(hdnExistingPayeeId.Value)) { newPayee.PayeeId = System.Guid.NewGuid().ToString().ToUpper(); newPayee.DefaultName = txtName.Text; newPayee.DefaultStreetAddress = txtStreetAddress.Text; newPayee.DefaultStreetAddressTwo = txtStreetAddress2.Text; newPayee.DefaultCity = txtCity.Text; newPayee.DefaultPostalCode = txtPostalCode.Text; newPayee.DefaultRegion = ddlRegion.SelectedValue; newPayee.DefaultCountry = ddlCountry.Text; // Should be converted to a DDL in the future when more countries supported // Store into DB PayeeDb.InsertPayee(newPayee); } // Create UserPayee Association UserPayee newUserPayee = new UserPayee(); newUserPayee.UserPayeeId = System.Guid.NewGuid().ToString().ToUpper(); newUserPayee.UserId = User.Identity.GetUserId(); newUserPayee.PayeeId = String.IsNullOrEmpty(hdnExistingPayeeId.Value) ? newPayee.PayeeId : hdnExistingPayeeId.Value; newUserPayee.Nickname = txtNickname.Text; newUserPayee.PayeeAccountNumber = txtAccountNumber.Text; // Store into DB UserPayeeDb.InsertUserPayee(newUserPayee); // Trigger confirmation Modal // Clear Values from Form txtName.Text = ""; txtStreetAddress.Text = ""; txtStreetAddress2.Text = ""; txtCity.Text = ""; txtPostalCode.Text = ""; ddlRegion.SelectedIndex = 0; txtNickname.Text = ""; txtAccountNumber.Text = ""; // Reset GridView1 and search query just in case txtSearchQuery.Text = ""; GridView1.DataBind(); }
public static int DeleteUserPayee(UserPayee userPayee) { int deleteCount = 0; string sql = "DELETE FROM UserPayees " + "WHERE UserPayeeId = @UserPayeeId"; using (SqlConnection con = new SqlConnection(GetConnectionString())) { using (SqlCommand cmd = new SqlCommand(sql, con)) { cmd.Parameters.AddWithValue("UserPayeeId", userPayee.UserPayeeId); con.Open(); deleteCount = cmd.ExecuteNonQuery(); } } return(deleteCount); }
public static void InsertUserPayee(UserPayee userPayee) { string sql = "INSERT INTO UserPayees " + "(UserPayeeId, UserId, PayeeId, Nickname, PayeeAccountNumber) " + "VALUES (@UserPayeeId, @UserId, @PayeeId, @Nickname, @PayeeAccountNumber)"; using (SqlConnection con = new SqlConnection(GetConnectionString())) { using (SqlCommand cmd = new SqlCommand(sql, con)) { cmd.Parameters.AddWithValue("UserPayeeId", userPayee.UserPayeeId); cmd.Parameters.AddWithValue("UserId", userPayee.UserId); cmd.Parameters.AddWithValue("PayeeId", userPayee.PayeeId); cmd.Parameters.AddWithValue("Nickname", userPayee.Nickname); cmd.Parameters.AddWithValue("PayeeAccountNumber", userPayee.PayeeAccountNumber); con.Open(); cmd.ExecuteNonQuery(); } } }
public static int UpdateUserPayee(UserPayee original_userPayee, UserPayee userPayee) { int updateCount = 0; string sql = "UPDATE UserPayees SET " + "Nickname = @Nickname, " + "PayeeAccountNumber = @PayeeAccountNumber " + "WHERE UserPayeeId = @original_UserPayeeId "; using (SqlConnection con = new SqlConnection(GetConnectionString())) { using (SqlCommand cmd = new SqlCommand(sql, con)) { cmd.Parameters.AddWithValue("Nickname", userPayee.Nickname); cmd.Parameters.AddWithValue("PayeeAccountNumber", userPayee.PayeeAccountNumber); cmd.Parameters.AddWithValue("original_UserPayeeId", original_userPayee.UserPayeeId); con.Open(); updateCount = cmd.ExecuteNonQuery(); } } return(updateCount); }