Dilsher Khan

Dilsher Khan

  • NA
  • 5
  • 1.2k

How to set bool value to true in mvc entityframework

Jul 2 2016 4:42 AM

Briefly

I'm creating a social site in MVC5..... I've a model User where i have some of these properties fname,lname,username,email,isNew...etc

so i've set isNew to false and when i press Login Button i've a if condition:

if(isNew==true) than redirect...to Index(A.M) Home(C) ....

else redirect....to NewUser(A.M) Steps(C)...

Now when i clicked Login Button its works pretty good i mean it redirect me to Steps(Controller) NewUser(ActionMethod) now here i want to set isNew value to true but i've no idea how to do this

This is what i have tried...

public ActionResult NewUser(User model) { 
using (DbAccess db=new DbAccess()) { 
var original=db.users.Find(model.uid);             
original.isNew = true; 
//var entry = db.Entry(original); 
//entry.Property(e => e.isNew).IsModified = true;             
db.SaveChanges(); } return Content("Welcome"); }

i'm new to Mvc/EntityFramework/Linq so no idea how to update this bool value...

Answers (2)