Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.84 KB | None | 0 0
  1.     public static void SeedTickets()
  2.         {
  3.  
  4.             try
  5.             {
  6.                 List<Projection> listProjection = Projection.All();
  7.                 List<User> listUsers = User.All();
  8.  
  9.  
  10.  
  11.                 List<Ticket> list = new List<Ticket> ( )
  12.                 {
  13.                    
  14. //                  new Ticket(listProjection[Methods.GetRandomInt(0,listProjection.Count-1)].ProjectionId, listUsers[Methods.GetRandomInt(0,listUsers.Count-1)].UserId, Methods.GetRandomInt(300,700), Methods.GetRandomInt(0,5), Methods.GetRandomInt(0,10)),
  15. //                  new Ticket(listProjection[Methods.GetRandomInt(0,listProjection.Count-1)].ProjectionId, listUsers[Methods.GetRandomInt(0,listUsers.Count-1)].UserId, Methods.GetRandomInt(300,700), Methods.GetRandomInt(0,5), Methods.GetRandomInt(0,10)),
  16. //                  new Ticket(listProjection[Methods.GetRandomInt(0,listProjection.Count-1)].ProjectionId, listUsers[Methods.GetRandomInt(0,listUsers.Count-1)].UserId, Methods.GetRandomInt(300,700), Methods.GetRandomInt(0,5), Methods.GetRandomInt(0,10)),
  17. //                  new Ticket(listProjection[Methods.GetRandomInt(0,listProjection.Count-1)].ProjectionId, listUsers[Methods.GetRandomInt(0,listUsers.Count-1)].UserId, Methods.GetRandomInt(300,700), Methods.GetRandomInt(0,5), Methods.GetRandomInt(0,10)),
  18. //                  new Ticket(listProjection[Methods.GetRandomInt(0,listProjection.Count-1)].ProjectionId, listUsers[Methods.GetRandomInt(0,listUsers.Count-1)].UserId, Methods.GetRandomInt(300,700), Methods.GetRandomInt(0,5), Methods.GetRandomInt(0,10))
  19. //
  20. //
  21.                     new Ticket(listProjection[Methods.GetRandomInt(0,listProjection.Count-1)].ProjectionId, listUsers[0].UserId, Methods.GetRandomInt(300,700), Methods.GetRandomInt(0,5), Methods.GetRandomInt(0,10)),
  22.                     new Ticket(listProjection[Methods.GetRandomInt(0,listProjection.Count-1)].ProjectionId, listUsers[0].UserId, Methods.GetRandomInt(300,700), Methods.GetRandomInt(0,5), Methods.GetRandomInt(0,10)),
  23.                     new Ticket(listProjection[Methods.GetRandomInt(0,listProjection.Count-1)].ProjectionId, listUsers[0].UserId, Methods.GetRandomInt(300,700), Methods.GetRandomInt(0,5), Methods.GetRandomInt(0,10)),
  24.                     new Ticket(listProjection[Methods.GetRandomInt(0,listProjection.Count-1)].ProjectionId, listUsers[0].UserId, Methods.GetRandomInt(300,700), Methods.GetRandomInt(0,5), Methods.GetRandomInt(0,10)),
  25.                     new Ticket(listProjection[Methods.GetRandomInt(0,listProjection.Count-1)].ProjectionId, listUsers[0].UserId, Methods.GetRandomInt(300,700), Methods.GetRandomInt(0,5), Methods.GetRandomInt(0,10))
  26.  
  27.                 };
  28.  
  29.    
  30.  
  31.                 if ( Serialization.isEmpty( Serialization.TiFile ) ){
  32.                     Console.WriteLine( "File is not exist. It will be created!" );
  33.                 }
  34.                 else{
  35.                     Console.WriteLine("File is exist! It will be recreated!");
  36.                 }
  37.  
  38.                 Console.WriteLine( "Writing... \n" );
  39.                 Serialization.WriteListToBinaryFile<Ticket>( Serialization.TiFile , list , false );
  40.  
  41.             }
  42.             catch ( Exception ex ){
  43.                 Console.WriteLine(ex.ToString());
  44.             }
  45.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement