public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Note")] Touring touring) { if (id != touring.TouringId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(touring); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TouringExists(touring.TouringId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(touring)); }
public async Task <IActionResult> Create([Bind("Id,Name,Note")] Touring touring) { if (ModelState.IsValid) { _context.Add(touring); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(touring)); }
internal void Add(string title, string note = "", string planTitle = "プランA") { var touring = new Touring { Title = title, Note = note, Plans = new List <Plan> { new Plan { Title = planTitle } }, }; _context.Tourings.Add(touring); _context.SaveChanges(); }