コード例 #1
0
 public void EditTeam(Team team)
 {
     using (var DBteams = new TeamContext())
     {
         DBteams.Entry(team).State = System.Data.Entity.EntityState.Modified;
         DBteams.SaveChanges();
     }
 }
コード例 #2
0
        public ActionResult Details(int id)
        {
            TeamContext teamContext = new TeamContext();

            Team team = teamContext.Team.Single(t => t.Id == id);

            ViewBag.IdOfLeader = team.Leader;
            team.Leader = GetLeaderName(team);

            var fighters = GetFightersOfTeam(team.Id);
            ViewBag.Fighters = fighters.FindAll(n => n.TeamConfirmed == true);

            ViewBag.HaveTeam = UserInTeam();
            ViewBag.IsSigned = UserSigned();

            return View(team);
        }
コード例 #3
0
        private bool ValidChange(string userName, string leaderId)
        {
            int? id1, id2;

            using (var usersDB = new ApplicationDbContext())
            {
                id1 = usersDB.Users.Where(u => u.UserName == userName).SingleOrDefault().InTeam;
            }

            using (var teamContext = new TeamContext())
            { 
                id2 = teamContext.Team.Where(s => s.Leader == leaderId).SingleOrDefault().Id;
            }

            if ( id1 == id2 )
            {
                return true;
            }

            return false;
        }
コード例 #4
0
        public ActionResult MyTeam()
        {
            TeamContext teamContext = new TeamContext();
            string id = User.Identity.GetUserId();
           
            Team team = teamContext.Team.FirstOrDefault(t => t.Leader == id);

            // if leader made a team
            if (team != null)
            { 
                var fighters = GetFightersOfTeam(team.Id);

                ViewBag.Fighters = fighters.FindAll(n => n.TeamConfirmed == true);
                var waitingFighters = fighters.FindAll(n => n.TeamConfirmed == false);

                ViewBag.AreWaitingFighters = true;
                if (waitingFighters.Count == 0)
                {
                    ViewBag.AreWaitingFighters = false;
                }

                ViewBag.WaitingFighters = waitingFighters;
                return View(team);
            } else { 
                team = new Team();
                team.Id = -1;
                return View(team);
            }
        }
コード例 #5
0
        public ActionResult Edit(int id)
        {
            var teams = new TeamContext();
            Team team = teams.Team.Single(x => x.Id == id);
            UpdateModel(team, new string[] { "Name" });

            if (ModelState.IsValid)
            {
                teams.EditTeam(team);

                return RedirectToAction("MyTeam");
            }
            return View(team);  
        }
コード例 #6
0
        public ActionResult Edit()
        {
            var teams = new TeamContext();
            IEnumerable<Team> listOfTeams = teams.Team.ToList().Where(x => x.Leader == User.Identity.GetUserId());

            var team = new Team();
            team = listOfTeams.First();

            return View(team);
        }
コード例 #7
0
        public ActionResult All()
        {
            var teams = new TeamContext();
            List<Team> listOfTeams = teams.Team.ToList();

            return View(listOfTeams);
        }