public async Task <IActionResult> Edit(int id, [Bind("Id,Title,CreateTime,LastUpdateTime,CompetitionFieldId")] CompetitionBranch competitionBranch) { if (id != competitionBranch.Id) { return(NotFound()); } if (ModelState.IsValid) { try { competitionBranch.LastUpdateTime = DateTime.Now; _context.Update(competitionBranch); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CompetitionBranchExists(competitionBranch.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CompetitionFieldId"] = new SelectList(_context.CompetitionFields, "Id", "Title", competitionBranch.CompetitionFieldId); return(View(competitionBranch)); }
public async Task <IActionResult> Create([Bind("Id,Title,CreateTime,LastUpdateTime,CompetitionFieldId")] CompetitionBranch competitionBranch) { if (ModelState.IsValid) { competitionBranch.CreateTime = DateTime.Now; _context.Add(competitionBranch); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CompetitionFieldId"] = new SelectList(_context.CompetitionFields, "Id", "Title", competitionBranch.CompetitionFieldId); return(View(competitionBranch)); }