2
Answers

assigning ramdom numbers for all existing user

Ask a question
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
 
 
 
  1. public ActionResult Test(User user)  
  2.      {  
  3.            
  4.          Random rand = new Random();  
  5.          int numero = rand.Next(1, 10000);  
  6.          var model = new User();  
  7.          
  8.           
  9.          model.UserId = user.UserId;  
  10.          model.Nombre = user.Nombre;                       
  11.          model.Codigo = numero;  
  12.   
  13.            
  14.          db.Users.Add(model);  
  15.          db.SaveChanges();  
  16.          return View(model);  
  17.            
  18.      }  

Answers (2)