Ejemplo n.º 1
0
        public void populateDb()
        {
            Events events = new Events()
            {
                Name      = "Black Coffee Tirane",
                EventDate = DateTime.ParseExact("2019-04-08 23:30:00", "yyyy-MM-dd HH:mm:ss",
                                                System.Globalization.CultureInfo.InvariantCulture),
                Tickets = new List <Tickets>()
            };

            // Random rnd = new Random();

            // events.Tickets.Add(new Tickets(){
            //     Barcode = "3850322007099",
            //     IsActivated = false
            // });
            // int x = 1;
            // while(x<50){
            //     long barcode = rnd.Next(10000000,99999999);
            //     foreach(Tickets tickets in events.Tickets){
            //         if(tickets.Barcode.Equals(barcode+"")){
            //             continue;
            //         }
            //     }
            //     var ticket = new Tickets(){
            //         Barcode = barcode.ToString(),
            //         IsActivated = false
            //     };

            //     events.Tickets.Add(ticket);
            //     x++;
            // }
            Console.WriteLine(fakeBarcodes.Length + "");
            for (int x = 0; x < fakeBarcodes.Length; x++)
            {
                var ticket = new Tickets()
                {
                    Barcode     = fakeBarcodes[x],
                    IsActivated = false
                };

                events.Tickets.Add(ticket);
                x++;
            }

            db.Events.Add(events);
            db.SaveChanges();
        }
Ejemplo n.º 2
0
 public bool UpdateTicket(Tickets ticket)
 {
     ticket.ActivatedAt = DateTime.Now;
     ticket.IsActivated = true;
     return(db.SaveChanges() > 0);
 }