public GameEditViewModel(GameShelfContext db) { GameWithPersonInfo = new GameWithPersonInfo(); var playTimeQuery = db.Playtimes.OrderBy(pt => pt.ID); PlayTimeSelect = new SelectList(playTimeQuery, "ID", "PlayTimeCategory"); var personQuery = db.People.OrderBy(p => p.LastName).ThenBy(p => p.FirstName); AllPersonsData = new List <AssignedPersonData>(); foreach (Person person in personQuery) { AllPersonsData.Add(new AssignedPersonData { PersonID = person.ID, FullName = person.FullName }); } }
public async Task <IActionResult> Delete(int?id) { if (id == null) { return(NotFound()); } var game = await db.Games .Include(g => g.PlayTime) .Include(g => g.GamePersonRelationships) .ThenInclude(gpr => gpr.Person) .SingleOrDefaultAsync(m => m.ID == id); var gpi = new GameWithPersonInfo(game); if (gpi == null) { return(NotFound()); } return(View(gpi)); }
public GameEditViewModel() { GameWithPersonInfo = new GameWithPersonInfo(); }