Esempio n. 1
0
        // EVENTS

        static void SeedEvent(RazorPage_uppgiftContext context, UserManager <MyUser> userManager)
        {
            //context.Database.EnsureDeleted();
            context.Database.EnsureCreated();
            context.SaveChanges();

            if (context.Events.Any())
            {
                return;
            }

            var organizerUser = context.MyUsers.Where(u => u.FirstName == "Codeboss").FirstOrDefault();

            var events = new Event[]
            {
                new Event {
                    Title          = "Stuff N Things",
                    Description    = "Doing fun stuff and things that everybody likes.",
                    Place          = "Fun Arena",
                    Address        = "20 Fun Street, Bean City",
                    Date           = DateTime.Parse("2021-06-19 13:00"),
                    SpotsAvailable = 0,
                    Organizer      = organizerUser
                },

                new Event {
                    Title          = "Awful Event",
                    Description    = "Come to this awful event if you dare.",
                    Place          = "Awful Arena",
                    Address        = "127 Awful Ave, Bean City",
                    Date           = DateTime.Parse("2021-09-01 16:00"),
                    SpotsAvailable = 97,
                    Organizer      = organizerUser
                },

                new Event {
                    Title          = "Llama spitting",
                    Description    = "Wanna get spit by a Llama? Welcome to Llama Park.",
                    Place          = "Llama Park",
                    Address        = "89 Llama Street, SimCity",
                    Date           = DateTime.Parse("2021-05-11 12:00"),
                    SpotsAvailable = 25,
                    Organizer      = organizerUser
                },

                new Event {
                    Title          = "Dankey Kongs banana party",
                    Description    = "Lots of bananas collected by an infamous ape will be shared to everyone who attends.",
                    Place          = "Munky Cheez",
                    Address        = "100 Jungle Lane, Bananaland",
                    Date           = DateTime.Parse("2021-08-13 13:00"),
                    SpotsAvailable = 1,
                    Organizer      = organizerUser
                },
            };

            context.Events.AddRange(events);
            context.SaveChanges();
        }
Esempio n. 2
0
 public static void Initialize(RazorPage_uppgiftContext context, UserManager <MyUser> userManager, RoleManager <IdentityRole> roleManager)
 {
     {
         SeedRoles(context, roleManager);
         SeedUsers(userManager);
         SeedEvent(context, userManager);
     }
 }
Esempio n. 3
0
 public MyHandler(
     RazorPage_uppgiftContext context,
     UserManager <MyUser> userManager,
     IHttpContextAccessor httpContextAccessor
     )
 {
     _context             = context;
     _userManager         = userManager;
     _httpContextAccessor = httpContextAccessor;
 }
Esempio n. 4
0
        // ROLES

        static void SeedRoles(RazorPage_uppgiftContext context, RoleManager <IdentityRole> roleManager)
        {
            //context.Database.EnsureDeleted();
            context.Database.EnsureCreated();
            context.SaveChanges();

            string[] roleNames = { "Admin", "Organizer", "Attendee" };


            foreach (var roleName in roleNames)
            {
                if (!roleManager.RoleExistsAsync(roleName).Result)
                {
                    IdentityRole role = new IdentityRole();
                    role.Name = roleName;
                    IdentityResult roleResult = roleManager.CreateAsync(role).Result;
                }
            }
        }
Esempio n. 5
0
 public IndexModel(RazorPage_uppgiftContext context)
 {
     _context = context;
 }
Esempio n. 6
0
 public DeleteModel(RazorPage_uppgiftContext context)
 {
     _context = context;
 }
Esempio n. 7
0
        public static void Initialize(RazorPage_uppgiftContext context)
        {
            if (context.Attendees.Any() ||
                context.Events.Any() ||
                context.Organizers.Any() ||
                context.JoinedEvents.Any())
            {
                Console.WriteLine("Data found in db, if you want the mock data provided in seed, open pmc " +
                                  "and type : 'Drop-Database -Confirm'");
                return;
            }


            // Attendees

            Attendee[] attendees = new Attendee[] {
                new Attendee {
                    Name = "John Stranger", Email = "*****@*****.**", PhoneNumber = "2222111121"
                }
            };
            context.AddRange(attendees);
            context.SaveChanges();


            // Organizers

            Organizer[] organizers = new Organizer[] {
                new Organizer {
                    Name = "JonaZ", Email = "*****@*****.**", PhoneNumber = "1555555555"
                },
                new Organizer {
                    Name = "The Plumbers", Email = "*****@*****.**", PhoneNumber = "0766666666"
                },
            };
            context.AddRange(organizers);
            context.SaveChanges();


            // Events

            Event[] events = new Event[] {
                new Event {
                    Title          = "Stuff N things",
                    Organizer      = organizers[0],
                    Description    = "Doing fun stuff and things that everybody likes.",
                    Address        = "20 Fun Street, Bean City",
                    Date           = DateTime.Parse("2021-06-19 12:00"),
                    SpotsAvailable = 0
                },


                new Event {
                    Title          = "Awful event",
                    Organizer      = organizers[0],
                    Description    = "Come to this awful event if you dare.",
                    Address        = "127 Awful Ave, Bean City",
                    Date           = DateTime.Parse("2021-04-01 14:00"),
                    SpotsAvailable = 97
                },

                new Event {
                    Title          = "Llama spitting",
                    Organizer      = organizers[1],
                    Description    = "Wanna get spit by a Llama? Welcome to Llama Street.",
                    Address        = "Llama Street, Bean City",
                    Date           = DateTime.Parse("2021-05-11 12:00"),
                    SpotsAvailable = 18
                },

                new Event {
                    Title          = "Dankey Kongs banana party",
                    Organizer      = organizers[1],
                    Description    = "Lots of bananas collected by an infamous ape will be shared to everyone who attends.",
                    Address        = "100 Jungle Lane, Bananaland",
                    Date           = DateTime.Parse("2021-05-03 18:00"),
                    SpotsAvailable = 1
                },
            };
            context.AddRange(events);
            context.SaveChanges();
        }
Esempio n. 8
0
 public DetailsModel(RazorPage_uppgiftContext context)
 {
     _context = context;
 }