Mark Tabor

Mark Tabor

  • 587
  • 2k
  • 457.1k

Updating identity table aspnetuser in mvc web application

Mar 30 2020 10:16 PM
I am using asp.net identity for signup and signin for email confirmation i am using my own code but on email confirmation i want to update the records in aspnetuser table like emailconfirmed field to true , but it is not updating
and db.savechanges()>0 always false
check the below code.
  1. public JsonResult RegisterConfirm(string regId)  
  2. {  
  3. OurHealthisWealthEntities db = new OurHealthisWealthEntities();  
  4. var userList = UserManager.Users.Where(x=>x.Id==regId).FirstOrDefault();  
  5. userList.EmailConfirmed = true;  
  6. userList.PhoneNumber = "123123123123";  
  7. //db.Entry(userList).State = EntityState.Modified;  
  8. if (db.SaveChanges()>0)  
  9. {  
  10. var msg = "Your Email Is Verified!";  
  11. return Json(msg, JsonRequestBehavior.AllowGet);  
  12. }  
  13. else  
  14. {  
  15. var msg = "your email is not verified!";  
  16. return Json(msg, JsonRequestBehavior.AllowGet);  
  17. }  
  18. }  
Even committed line when uncomment it still not updating the record

Answers (12)