示例#1
0
        public IActionResult ViewUser(int id)
        {
            BrightIdeaVM GetUser = new BrightIdeaVM()
            {
                ThisUser = dbContext.Users.FirstOrDefault(u => u.UserId == id)
            };

            return(View("ViewUser", GetUser));
        }
示例#2
0
        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));
        }
示例#3
0
        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));
            }
        }
示例#4
0
 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));
     }
 }