Exemple #1
0
        public async Task <IActionResult> Edit(int id, [Bind("EventId,OrganizationId,Id")] SponsorInEvent sponsorInEvent)
        {
            if (id != sponsorInEvent.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(sponsorInEvent);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SponsorInEventExists(sponsorInEvent.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EventId"]        = new SelectList(_context.Events, "Id", "Id", sponsorInEvent.EventId);
            ViewData["OrganizationId"] = new SelectList(_context.Organizations, "Id", "Id", sponsorInEvent.OrganizationId);
            return(View(sponsorInEvent));
        }
Exemple #2
0
        public async Task <IActionResult> Create([Bind("EventId,OrganizationId,Id")] SponsorInEvent sponsorInEvent)
        {
            if (ModelState.IsValid)
            {
                _context.Add(sponsorInEvent);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EventId"]        = new SelectList(_context.Events, "Id", "Id", sponsorInEvent.EventId);
            ViewData["OrganizationId"] = new SelectList(_context.Organizations, "Id", "Id", sponsorInEvent.OrganizationId);
            return(View(sponsorInEvent));
        }