public IActionResult NewLeader(string id) { var viewmodel = new NewLeaderViewModel(); // string Sql = "select Id,FirstName,LastName,PhoneNumber from AspNetUsers"; // var temp = _context.ApplicationUser.FromSql(Sql).ToList(); var temp = _context.ApplicationUser.Select(a => new { a.Id, a.FirstName, a.LastName, a.PhoneNumber }).ToList(); var Leaderlist = new List <Leader>(); TempData["Teamid"] = id; foreach (var item in temp) { var sm = new Leader(); sm.LeaderId = item.Id; sm.FirstName = item.FirstName; sm.LastName = item.LastName; sm.Contact = item.PhoneNumber; Leaderlist.Add(sm); } viewmodel.TeamId = id; viewmodel.Leaders = Leaderlist; return(View("NewLeader", viewmodel)); }
public ActionResult ConfirmLeader(NewLeaderViewModel NewLeader) { _context.Teams.Where(a => a.TeamId == NewLeader.TeamId).First().TeamLeaderID = NewLeader.LeaderId; _context.SaveChanges(); return(RedirectToAction("Details", new { id = NewLeader.TeamId })); }