コード例 #1
0
        public async Task<IActionResult> Create(CreerSquadViewModel squad)
        {
            if (ModelState.IsValid)
            {
                Squad leSquad = new Squad(squad, CurrentUser.GetUserId());
                // addedSquad.Entity.Id;

                EntityEntry<Squad> addedSquad = _context.Squads.Add(leSquad);
                await _context.SaveChangesAsync();
                return RedirectToAction("Index");
            }
            ViewData["UserId"] = new SelectList(_context.AppUser, "Id", "User", CurrentUser.GetUserId());
            return View(squad);
        }
コード例 #2
0
 public async Task<IActionResult> Edit(Squad squad)
 {
     if (ModelState.IsValid)
     {
         _context.Update(squad);
         await _context.SaveChangesAsync();
         return RedirectToAction("Index");
     }
     ViewData["UserId"] = new SelectList(_context.AppUser, "Id", "User", squad.UserId);
     return View(squad);
 }