Beispiel #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id")] FunZone funZone)
        {
            if (id != funZone.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(funZone);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FunZoneExists(funZone.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(funZone));
        }
Beispiel #2
0
        public async Task <IActionResult> Create([Bind("Id")] FunZone funZone)
        {
            if (ModelState.IsValid)
            {
                _context.Add(funZone);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(funZone));
        }
Beispiel #3
0
        private static void SeedEnumerations(ISAContext context)
        {
            for (var i = 0; i < 3; i++)
            {
                var dummyUser = new UserProfile
                {
                    City         = $"City{i}",
                    EmailAddress = $"test{i}@test.mail",
                    FirstName    = $"FirstName{i}",
                    LastName     = $"LastName{i}",
                    TelephoneNr  = $"{i}{i}{i}{i}{i}{i}{i}"
                };

                if (context.UserProfiles.All(u => u.EmailAddress != dummyUser.EmailAddress))
                {
                    context.UserProfiles.Add(dummyUser);
                }
            }

            context.SaveChanges();

            var twoUsers   = context.UserProfiles.Take(2);
            var firstUser  = twoUsers.First();
            var secondUser = twoUsers.Skip(1).Take(1).First();

            if (context.FriendRequests.All(r => r.SenderId != firstUser.Id && r.ReceiverId != secondUser.Id))
            {
                context.FriendRequests.Add(new FriendRequest
                {
                    Sender   = firstUser,
                    Receiver = secondUser,
                    Status   = FriendshipStatus.Pending
                });
            }

            var projection = new Projection
            {
                Description = "desc",
                Duration    = new System.TimeSpan(2, 0, 0),
                Name        = "Projection 1",
                Type        = ProjectionTypeEnum.Movie
            };


            var rep = new Repertoire
            {
                Projections = new List <Projection> {
                    projection
                }
            };

            var cinema = new Cinema
            {
                Address     = "Address1",
                Name        = "Cinema1",
                Type        = DataAccess.Models.Enumerations.CinemaTypeEnum.Cinema,
                Repertoires = new List <Repertoire> {
                    rep
                }
            };

            var theater = new Theater()
            {
                Name = "Pozoriste Mladih"
            };

            var funZone = new FunZone()
            {
                Cinema = cinema
            };

            var funZoneTheater = new FunZone()
            {
                Theater = theater
            };

            var starWarsProps = new ThematicProps()
            {
                FunZone     = funZone,
                Description = "An almost brand new thematic prop for star wars! Used couple of times!",
                Image       = @"‪~/images/sw1.jpg",
                Price       = 1000,
                Name        = "Star wars gear",
                Publisher   = firstUser
            };

            var starTreckProp = new ThematicProps()
            {
                FunZone     = funZone,
                Description = "An almost brand new thematic prop for star treck! Used couple of times!",
                Image       = @"‪~/images/st1.jpg",
                Price       = 2000,
                Name        = "Star treck terminal"
            };

            var lotrProp = new ThematicProps()
            {
                FunZone     = funZone,
                Description = "An almost brand new thematic prop for LOTR! Used couple of times!",
                Image       = @"~/images/lordOfRings_ring.jpg",
                Price       = 200000,
                Name        = "LOTR ring on sales"
            };

            context.ThematicProps.Add(starWarsProps);
            context.ThematicProps.Add(starTreckProp);
            context.ThematicProps.Add(lotrProp);
            context.Projections.Add(projection);
            context.Repertoires.Add(rep);
            context.Cinemas.Add(cinema);
            context.FunZone.Add(funZone);
            context.FunZone.Add(funZoneTheater);

            context.SaveChanges();
        }