Beispiel #1
0
 public ActionResult AddTeam(CUserTeamSpecs team)
 {
     // ------------------------------------------
     try {
         ViewBag.Msg = "";
         if (team.TeamName == "" || team.TeamName == null)
         {
             ViewBag.Msg = "You must enter a team name";
         }
         else if (team.TeamName.Length > 30)
         {
             ViewBag.Msg = "Team name is too long (30 characters max)";
         }
         else
         {
             bool exists = info.TeamNameExists(team.UserName, team.TeamName);
             if (exists)
             {
                 ViewBag.Msg = "You already have a team named " + team.TeamName;
             }
         }
         if (ViewBag.Msg != "")
         {
             return(View(team));
         }
         else
         {
             info.AddNewTeam(team.UserName, team.TeamName, team.UsesDh);
             var view = new TeamListVM(team.UserName, info);
             return(View("TeamList", view));
         }
     }
     catch (Exception ex) {
         string msg =
             "An error occurred adding the new team to the database:\r\n" +
             ex.Message;
         ViewBag.ErrorMsg = msg;
         return(View("ErrorView"));
     }
 }