public async Task <IActionResult> Create([Bind("Sport,Label")] Season season) { await _seasonModelStatePopulator.ValidateAndPopulateForCreate(ModelState, season); if (ModelState.IsValid) { await _seasonService.PersistSeason(season); return(RedirectToAction(nameof(Index))); } return(View(await _seasonService.GetNew())); }
public async Task <IActionResult> Create([Bind("Name,FullName")] Sport sport) { await _sportModelStatePopulator.ValidateAndPopulateForCreate(ModelState, sport); if (ModelState.IsValid) { _context.Add(sport); await _context.SaveChangesAsync(); return(RedirectToAction(actionName: nameof(Index))); } return(View(sport)); }
public async Task <IActionResult> Create([Bind("Name,Country")] Venue venue) { await _venueModelStatePopulator.ValidateAndPopulateForCreate(ModelState, venue); if (ModelState.IsValid) { _context.Add(venue); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["Country"] = new SelectList(_context.Country.OrderBy(_ => _.NiceName), "Iso", "Iso", venue.Country); return(View(venue)); }
public async Task <IActionResult> Create([Bind("Id,Title,FirstName,LastName,Country")] Participant participant) { await _participantModelStatePopulator.ValidateAndPopulateForCreate(ModelState, participant); if (ModelState.IsValid) { _context.Add(participant); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["Country"] = new SelectList(_context.Country.OrderBy(_ => _.NiceName), "Iso", "NiceName", participant.Country); return(View(participant)); }
public async Task <IActionResult> Create([Bind("Id,Name,Sport,Country")] Team team) { await _teamModelStatePopulator.ValidateAndPopulateForCreate(ModelState, team); if (ModelState.IsValid) { _context.Add(team); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["Country"] = new SelectList(_context.Country.OrderBy(_ => _.NiceName), "Iso", "Iso", team.Country); ViewData["Sport"] = new SelectList(_context.Sport.OrderBy(_ => _.Name), "Name", "Name", team.Sport); return(View(team)); }
public async Task <IActionResult> Create(int?id, [Bind("Season,Date,Number,Name,Venue,Status")] Round round) { if (id == null) { return(NotFound()); } await _roundModelStatePopulator.ValidateAndPopulateForCreate(ModelState, round); if (ModelState.IsValid) { await _roundService.PersistRound(round); return(RedirectToAction(nameof(Index), new { id = id.Value })); } var roundDisplayModel = await _roundService.CreateForRound(round); if (roundDisplayModel == null) { return(NotFound()); } return(View(roundDisplayModel)); }
public async Task <IActionResult> Create(int?id, [Bind("Season,Team,Name")] SeasonEntry seasonEntry) { if (id == null) { return(NotFound()); } await _seasonEntryModelStatePopulator.ValidateAndPopulateForCreate(ModelState, seasonEntry); if (ModelState.IsValid) { await _seasonEntryService.PersistSeasonEntry(seasonEntry); return(RedirectToAction(nameof(Index), new { id = id.Value })); } var seasonEntryDisplayModel = await _seasonEntryService.GetNew(id.Value); if (seasonEntryDisplayModel == null) { return(NotFound()); } return(View(seasonEntryDisplayModel)); }