I have register 5 users in my app. I need assigning ramdom number for all of them but I cant I have no idea how to do that. It´s Like a temporary PIN for authentication. I have that code but only create the number , not insert the number to users
- public ActionResult Test(User user)
- {
- Random rand = new Random();
- int numero = rand.Next(1, 10000);
- var model = new User();
- model.UserId = user.UserId;
- model.Nombre = user.Nombre;
- model.Codigo = numero;
- db.Users.Add(model);
- db.SaveChanges();
- return View(model);
- }
2 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Pedro CarvalloPosted Oct 18, 2017, 12:23 AM
SandyPosted Oct 17, 2017, 11:37 PM