hi
I create MVC project and want to insert data into database I use EntityFrameworks
but here when I run page and fill textboxs and click button to inserting data into database it doesnt insert data into database it didnt make any error but didn't insert data into database
below are codes
controller
public ActionResult register(User user)
{
if (ModelState.IsValid == true)
{
//stud.BirthDate = stud.BirthDate.Value.ToMiladi();
if (bl.Add(user) == true)
{
ViewBag.Message = "ثبت شد";
ViewBag.Style = "lightgreen";
}
else
{
ViewBag.Message = "ثبت نشد";
ViewBag.Style = "palevioletred";
}
}
else
{
ViewBag.Message = "مقادیر را بدرستی وارد کنید";
ViewBag.Style = "palevioletred";
}
return View();
}
and UserRepository.cs
MvcShopDbEntities db = new MvcShopDbEntities();
public bool Add(User user)
{
try
{
db.Users.Add(user);
return Convert.ToBoolean(db.SaveChanges());
}
catch (Exception)
{
return false;
}
}
I debugged it and took video
please see below video
https://vimeo.com/328467983
where is my mistake?
Best regards
neda