Ejemplo n.º 1
0
        public void TestInitialize()
        {
            var options = new DbContextOptionsBuilder <f19Context>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            db = new f19Context(options);

            var studio = new Studio
            {
                StudioId = 502,
                Name     = "Some Studio"
            };

            movies.Add(new Movie
            {
                MovieId = 11,
                Title   = "Movie One",
                Year    = 2017,
                Revenue = 100000,
                Studio  = studio
            });

            movies.Add(new Movie
            {
                MovieId = 22,
                Title   = "Movie Two",
                Year    = 2018,
                Revenue = 200000,
                Studio  = studio
            });

            movies.Add(new Movie
            {
                MovieId = 33,
                Title   = "Movie Three",
                Year    = 2016,
                Revenue = 300000,
                Studio  = studio
            });

            movies.Add(new Movie
            {
                MovieId = 44,
                Title   = "Movie Four",
                Year    = 2019,
                Revenue = 400000,
                Studio  = studio
            });

            foreach (var p in movies)
            {
                db.Add(p);
            }

            db.SaveChanges();
            moviesController = new MoviesController(db);
        }
Ejemplo n.º 2
0
        public void TestInitialize()
        {
            var options = new DbContextOptionsBuilder <f19Context>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            db = new f19Context(options);

            var region = new Region
            {
                RegionId = 871,
                Name     = "Oceania"
            };

            destinations.Add(new Destination
            {
                DestinationId = 534,
                Name          = "One Cool Place",
                Location      = "South Oz",
                Region        = region
            });

            destinations.Add(new Destination
            {
                DestinationId = 535,
                Name          = "Second Cool Place",
                Location      = "West Oz",
                Region        = region
            });

            destinations.Add(new Destination
            {
                DestinationId = 536,
                Name          = "Third Cool Place",
                Location      = "North Oz",
                Region        = region
            });

            destinations.Add(new Destination
            {
                DestinationId = 537,
                Name          = "Fourth Cool Place",
                Location      = "East Oz",
                Region        = region
            });

            foreach (var d in destinations)
            {
                db.Add(d);
            }

            db.SaveChanges();
            destinationsController = new DestinationsController(db);
        }
        public async Task <IActionResult> Create([Bind("PartyId,Name,Logo")] Party party)
        {
            if (ModelState.IsValid)
            {
                _context.Add(party);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(party));
        }
        public async Task <IActionResult> Create([Bind("RidingId,Name")] Riding riding)
        {
            if (ModelState.IsValid)
            {
                _context.Add(riding);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(riding));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("StudioId,Name")] Studio studio)
        {
            if (ModelState.IsValid)
            {
                _context.Add(studio);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(studio));
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Create([Bind("MovieId,Title,Year,Revenue,StudioId,Poster")] Movie movie)
        {
            if (ModelState.IsValid)
            {
                _context.Add(movie);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["StudioId"] = new SelectList(_context.Studio, "StudioId", "Name", movie.StudioId);
            return(View(movie));
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> Create([Bind("ElectionId,Year,PartyId,Majority")] Election election)
        {
            if (ModelState.IsValid)
            {
                _context.Add(election);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PartyId"] = new SelectList(_context.Party, "PartyId", "Name", election.PartyId);
            return(View(election));
        }
        public async Task <IActionResult> Create([Bind("DestinationId,Name,Location,Description,Photo,RegionId")] Destination destination)
        {
            if (ModelState.IsValid)
            {
                _context.Add(destination);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RegionId"] = new SelectList(_context.Region, "RegionId", "Name", destination.RegionId);
            return(View(destination));
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> Create([Bind("CandidateId,FirstName,LastName,PartyId,RidingId")] Candidate candidate)
        {
            if (ModelState.IsValid)
            {
                _context.Add(candidate);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PartyId"]  = new SelectList(_context.Party, "PartyId", "Name", candidate.PartyId);
            ViewData["RidingId"] = new SelectList(_context.Riding, "RidingId", "Name", candidate.RidingId);
            return(View(candidate));
        }