Beispiel #1
0
        public IActionResult Dashboard()
        {
            int?thisUserId = HttpContext.Session.GetInt32("UserId");

            if (thisUserId == null)
            {
                return(View("Index"));
            }
            else
            {
                BeltWrapper vMod      = new BeltWrapper();
                int         oneUserId = (int)HttpContext.Session.GetInt32("UserId");

                vMod.Hobbies = dbContext.Hobbies
                               .Include(u => u.AllAssociations)
                               .Include(u => u.User)
                               .ThenInclude(u => u.CreatedHobbies)
                               .ToList();

                vMod.User = dbContext.Users
                            .Include(u => u.CreatedAssociations)
                            .ThenInclude(h => h.Hobby)
                            .FirstOrDefault(u => u.UserId == oneUserId);

                return(View(vMod));
            }
        }
Beispiel #2
0
        public IActionResult ViewOneActivity(int sportId)
        {
            BeltWrapper oneSport   = new BeltWrapper();
            int?        thisUserId = HttpContext.Session.GetInt32("UserId");

            if (thisUserId == null)
            {
                return(View("Index"));
            }
            else
            {
                int oneUserId = (int)HttpContext.Session.GetInt32("UserId");
                oneSport.Sport = dbContext.Sports
                                 .Include(s => s.AllAssociations)
                                 .ThenInclude(u => u.User)
                                 .SingleOrDefault(s => s.SportId == sportId);

                oneSport.AllSports = dbContext.Sports
                                     .Include(u => u.AllAssociations)
                                     .ToList();

                oneSport.User = dbContext.Users
                                .Include(u => u.CreatedAssociation)
                                .ThenInclude(s => s.Sport)
                                .FirstOrDefault(u => u.UserId == oneUserId);

                return(View(oneSport));
            }
        }
Beispiel #3
0
 public IActionResult HPAssociation(int proficiencyId, BeltWrapper fromForm)
 {
     fromForm.Association.ProficiencyId = proficiencyId;
     dbContext.Add(fromForm.Association);
     dbContext.SaveChanges();
     return(RedirectToAction("Dashboard"));
 }
Beispiel #4
0
        public IActionResult BeltDashboard()
        {
            int?thisUserId = HttpContext.Session.GetInt32("UserId");

            if (thisUserId == null)
            {
                return(View("Index"));
            }
            else
            {
                BeltWrapper vMod      = new BeltWrapper();
                int         oneUserId = (int)HttpContext.Session.GetInt32("UserId");

                vMod.User = dbContext.Users
                            .Include(u => u.CreatedAssociation)
                            .ThenInclude(s => s.Sport)
                            .FirstOrDefault(u => u.UserId == oneUserId);

                vMod.AllSports = dbContext.Sports
                                 .Include(u => u.AllAssociations)
                                 .Include(u => u.User)
                                 .ThenInclude(u => u.CreatedSports)
                                 .OrderBy(d => d.Date)
                                 .ToList();
                // Also don't forget to use linq queries to display information
                // Don't forget to redirect to the approiate Method
                return(View(vMod));
            }
        }
Beispiel #5
0
        public IActionResult ViewOneHobby(int hobbyId)
        {
            BeltWrapper oneHobby   = new BeltWrapper();
            int?        thisUserId = HttpContext.Session.GetInt32("UserId");

            if (thisUserId == null)
            {
                return(View("Index"));
            }
            else
            {
                int oneUserId = (int)HttpContext.Session.GetInt32("UserId");
                oneHobby.Hobby = dbContext.Hobbies
                                 .Include(h => h.AllAssociations)
                                 .ThenInclude(u => u.User)
                                 .SingleOrDefault(h => h.HobbyId == hobbyId);

                oneHobby.Hobbies = dbContext.Hobbies
                                   .Include(u => u.AllAssociations)
                                   .Include(u => u.User)
                                   .ThenInclude(u => u.CreatedHobbies)
                                   .ToList();

                oneHobby.User = dbContext.Users
                                .Include(u => u.CreatedAssociations)
                                .ThenInclude(h => h.Hobby)
                                .FirstOrDefault(u => u.UserId == oneUserId);

                oneHobby.Proficiencies = dbContext.Proficiencies
                                         .Include(u => u.User)
                                         .ThenInclude(p => p.CreatedProficiencyLevels)
                                         .ToList();

                return(View(oneHobby));
            }
        }