public IActionResult ViewUser(int id) { BrightIdeaVM GetUser = new BrightIdeaVM() { ThisUser = dbContext.Users.FirstOrDefault(u => u.UserId == id) }; return(View("ViewUser", GetUser)); }
public IActionResult ViewIdea(int id, int uid) { BrightIdeaVM Idea = new BrightIdeaVM() { GetIdea = dbContext.BrightIdeas .Include(l => l.Likes) .ThenInclude(u => u.Liker) .FirstOrDefault(i => i.IdeaId == id), ThisUser = dbContext.Users.FirstOrDefault(u => u.UserId == uid) }; return(View("ViewIdea", Idea)); }
public IActionResult ShowIdeas() { int?GetIdInSession = HttpContext.Session.GetInt32("UserId"); if (GetIdInSession == null) { return(RedirectToAction("ShowLogin", "Login")); } else { BrightIdeaVM Idea = new BrightIdeaVM() { ThisUser = dbContext.Users.FirstOrDefault(u => u.UserId == GetIdInSession), AllIdeas = dbContext.BrightIdeas .Include(l => l.Likes) .ThenInclude(u => u.Liker) .OrderByDescending(c => c.CreatedAt) .ToList() }; return(View("Ideas", Idea)); } }
public IActionResult CreateIdea(BrightIdea NewIdea) { if (ModelState.IsValid) { dbContext.Add(NewIdea); dbContext.SaveChanges(); return(RedirectToAction("ShowIdeas")); } else { int? GetIdInSession = HttpContext.Session.GetInt32("UserId"); BrightIdeaVM GetUser = new BrightIdeaVM() { ThisUser = dbContext.Users.FirstOrDefault(u => u.UserId == GetIdInSession), AllIdeas = dbContext.BrightIdeas .Include(l => l.Likes) .ThenInclude(u => u.Liker) .OrderByDescending(c => c.CreatedAt) .ToList() }; return(View("Ideas", GetUser)); } }