public async Task <IActionResult> Create([Bind("Id,PassengerName,TrainScheduleId")] TrainTicket trainTicket)
        {
            if (ModelState.IsValid)
            {
                _context.Add(trainTicket);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(trainTicket));
        }
        public async Task <IActionResult> Create([Bind("Id,Name,Trophy,Year")] ChampionshipEntity championshipEntity)
        {
            if (ModelState.IsValid)
            {
                championshipEntity.Id = Guid.NewGuid();
                _context.Add(championshipEntity);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(championshipEntity));
        }
        private Ticket AddTicket(TicketInputModel ticket)
        {
            var result = new Ticket
            {
                AssigneeId  = ticket.AssigneeId,
                AssignerId  = ticket.AssignerId,
                Description = ticket.Description,
                Name        = ticket.Name,
                Priority    = ticket.Priority,
                State       = ticket.State
            };

            _context.Add(result);
            _context.SaveChangesAsync().GetAwaiter();
            return(result);
        }
Example #4
0
        public async Task <IActionResult> Create([Bind("Id,TeamHomeId,TeamAwayId,StadiumId,ChampionshipId")] GameEntity gameEntity)
        {
            if (ModelState.IsValid)
            {
                gameEntity.Id = Guid.NewGuid();
                _context.Add(gameEntity);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ChampionshipId"] = new SelectList(_context.Championships, "Id", "Id", gameEntity.ChampionshipId);
            ViewData["StadiumId"]      = new SelectList(_context.Stadiums, "Id", "Id", gameEntity.StadiumId);
            ViewData["TeamAwayId"]     = new SelectList(_context.Teams, "Id", "Id", gameEntity.TeamAwayId);
            ViewData["TeamHomeId"]     = new SelectList(_context.Teams, "Id", "Id", gameEntity.TeamHomeId);
            return(View(gameEntity));
        }