I have a data access layer to update and trying to call method on different page wont update database
i have tried moving some code around to be outside of the loop and also set a break point but the data doesn't reach the break point
Data access layer code (DAL):
public void editBuyerByID(int bID, string title, string fname, string lname, string email, string pWord, string tel,string pCode, double price, string type)
{
using (var context = dc)
{
Buyer editBuyer = (from b in context.Buyers where b.BuyerID == bID select b).FirstOrDefault();
if (editBuyer != null)
{
editBuyer.BuyerTitle = title;
editBuyer.BuyerFName = fname;
editBuyer.BuyerLName = lname;
editBuyer.BuyerEmail = email;
editBuyer.BuyerPassword = pWord;
editBuyer.BuyerTelNo = tel;
editBuyer.BuyerPostcode = pCode;
editBuyer.BuyerPriceRange = price;
editBuyer.BuyerType = type;
//context.Buyers.Add(editBuyer);
context.SaveChanges();
}
}
}
Account Page where method being called:
protected void btnUpdate_Click(object sender, EventArgs e)
{
try
{
aDal.editBuyerByID(Convert.ToInt32(Session["Buyer"].ToString()),
txtTitle.Text, txtFName.Text, txtLName.Text,
txtEmail.Text, txtPassword.Text, txtTelNo.Text, txtPostcode.Text, Convert.ToSingle(txtPrice.Text), txtType.Text);
string editBuyerScript = "alert(\"Your details have been updated\");";
ScriptManager.RegisterStartupScript(this, GetType(),
"ServerControlScript", editBuyerScript, true);
}
catch
{
string invalidScript = "alert(\"All fields must be filled correctly\");";
ScriptManager.RegisterStartupScript(this, GetType(),
"ServerControlScript", invalidScript, true);
}
}