Exemplo n.º 1
0
        public ActionResult GetSportSkillLvl(UserSportViewModel viewModel)
        {
            string id   = User.Identity.GetUserId();
            User   user = context.Users.Where(u => u.ApplicationId == id).FirstOrDefault();

            for (int i = 0; i < viewModel.sportSkillLevels.Count; i++)
            {
                SkillSportUser skillSportUser = new SkillSportUser()
                {
                    skillLevel = viewModel.sportSkillLevels[i].skillLevel,
                    SportId    = viewModel.sportSkillLevels[i].SportId,
                    UserId     = user.UserId
                };
                context.SkillSportUsers.Add(skillSportUser);
            }
            context.SaveChanges();
            return(RedirectToAction("Index", "Home", user));
        }
Exemplo n.º 2
0
        public ActionResult GetSportSkillLvl()
        {
            var sports      = context.Sports.AsNoTracking().ToList();
            var skillLevels = new List <SkillSportUser>();

            foreach (var sport in sports)
            {
                skillLevels.Add(new SkillSportUser {
                    SportId = sport.SportId, Sport = sport
                });
            }
            UserSportViewModel userSportViewModel = new UserSportViewModel()
            {
                SportList        = sports,
                sportSkillLevels = skillLevels
            };

            return(View(userSportViewModel));
        }