public async Task <IActionResult> PutDestination(int id, Destination destination)
        {
            if (id != destination.DestinationId)
            {
                return(BadRequest());
            }

            _context.Entry(destination).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DestinationExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutMovie(int id, Movie movie)
        {
            if (id != movie.MovieId)
            {
                return(BadRequest());
            }

            _context.Entry(movie).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MovieExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        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));
        }
Example #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));
        }
Example #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));
        }
        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));
        }
Example #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));
        }