Пример #1
0
        public ActionResult TeamConfrim(Team team)
        {
            if (ModelState.IsValid)
            {
                var response = _manager.CreateTeam(team);

                return View();
            }
            return View("NewTeam");
        }
Пример #2
0
        public void CreateTeam(Team team)
        {
            using (var context = new Models.BaseballLeagueEntities())
            {
                Models.Team newTeam = new Models.Team();
                newTeam.Manager = team.Manager;
                newTeam.TeamName = team.TeamName;
                newTeam.LeagueID = team.LeagueID;

                context.Teams.Add(newTeam);
                context.SaveChanges();
            }
        }
        public Response<Team> CreateTeam(Team team)
        {
            var response = new Response<Team>();
            var teams = _repo.GetAllTeamsByLeague(team.LeagueID);

            try
            {
                foreach (var t in teams)
                {
                    if (team.TeamName == t.TeamName)
                    {
                        response.Success = false;
                        response.Message = "There is already a team with that name in this league!";
                        return response;
                    }
                }
                _repo.CreateTeam(team);
                response.Success = true;
                response.Message = "Successfully created team.";
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Message = ex.Message;
            }
            return response;
        }
Пример #4
0
 private Team MapTeam(Models.Team from)
 {
     var to = new Team();
     //to.League = from.League;
     to.LeagueID = from.LeagueID;
     to.Manager = from.Manager;
     //to.Players = from.Players.ToList();
     to.TeamID = from.TeamID;
     to.TeamName = from.TeamName;
     return to;
 }