public ActionResult KnownSecrets(short?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Character character = db.Characters.Find(id); if (character == null) { return(HttpNotFound()); } var selfTags = from c in db.CharSecrets where c.CharId == character.CharacterId select c.SecretId ; var known = from t in db.SecretSecretTags where selfTags.Contains(t.SecretTagId) select t.Secret ; List <SecretComplete_PlayerVM> list = new List <SecretComplete_PlayerVM>() { }; foreach (Secret secret in known) { SecretComplete_PlayerVM toAdd = new SecretComplete_PlayerVM { Secret = secret, Tags = (from s in db.SecretSecretTags join st in db.SecretTags on s.SecretTagId equals st.SecretTagId where s.SecretId == secret.SecretId && selfTags.Contains(s.SecretTagId) select st) .ToList() }; list.Add(toAdd); } var tags = db.CharSecrets.Include(c => c.SecretTag).Where(c => c.CharId == id).Select(c => c.SecretTag).ToList(); SeePlayerSecrets model = new SeePlayerSecrets { CharacterName = character.CharacterName, CharId = character.CharacterId, Secrets = list, Tags = tags }; return(View(model)); }
//todo - thought: maybe I can change the hub into ajax. public PartialViewResult _Secrets() { var userId = User.Identity.GetUserId(); UserDetail user = db.UserDetails.Where(u => u.UserId == userId).First(); Character character = db.Characters.Where(c => c.CharacterId == user.CurrentCharacterId).First(); var selfTags = from c in db.CharSecrets where c.CharId == character.CharacterId select c.SecretId ; var known = from t in db.SecretSecretTags where selfTags.Contains(t.SecretTagId) select t.Secret ; List <SecretComplete_PlayerVM> list = new List <SecretComplete_PlayerVM>() { }; foreach (Secret secret in known) { SecretComplete_PlayerVM toAdd = new SecretComplete_PlayerVM { Secret = secret, Tags = (from s in db.SecretSecretTags join st in db.SecretTags on s.SecretTagId equals st.SecretTagId where s.SecretId == secret.SecretId && selfTags.Contains(s.SecretTagId) select st) .ToList() }; list.Add(toAdd); } //GetSecretHubVM known = new GetSecretHubVM(id); return(PartialView(list)); }