예제 #1
0
        public ActionResult Teams(string id)
        {
            int teamId;
            Team team = new Team();

            try
            {
                CheckUser(Models.Content.Teams);
                if (int.TryParse(id, out teamId))
                {
                    team = _data.GetTeamById(teamId);
                }
            }
            catch (Exception ex)
            {
                ErrorLog.WriteError("Edit Team", ex.Message);
            }
            return View(team);
        }
예제 #2
0
파일: IYFDData.cs 프로젝트: dtlydon/iyfd
 public bool CheckIfTeamExists(Team team)
 {
     using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["IYFD"].ToString()))
     {
         connection.Open();
         using (SqlCommand cmd = new SqlCommand("dbo.CheckTeamName", connection))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@name", team.Name);
             using (SqlDataReader reader = cmd.ExecuteReader())
             {
                 if (reader.Read())
                 {
                     return true;
                 }
                 else
                 {
                     return false;
                 }
             }
         }
     }
 }
예제 #3
0
        public ActionResult Teams(string id, string name)
        {
            try
            {
                CheckUser(Models.Content.Teams);
                int teamId;

                if (int.TryParse(id, out teamId))
                {
                    Team team = new Team
                    {
                        ID = teamId,
                        Name = name
                    };
                    _data.UpsertTeam(team);
                }
            }
            catch (Exception ex)
            {
                ErrorLog.WriteError("Edit Team", ex.Message);
            }
            return RedirectToAction("Teams", "Admin");
        }
예제 #4
0
파일: IYFDData.cs 프로젝트: dtlydon/iyfd
        public Team GetTeamById(int teamId)
        {
            Team team = new Team();
            using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["IYFD"].ToString()))
            {
                connection.Open();
                using (SqlCommand cmd = new SqlCommand("dbo.GetTeamById", connection))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@teamId", teamId);

                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            team.ID = Convert.ToInt32(reader["id"]);
                            team.Name = reader["name"].ToString();
                        }
                    }
                }
            }
            return team;
        }
예제 #5
0
파일: IYFDData.cs 프로젝트: dtlydon/iyfd
        public bool UpsertTeam(Team team)
        {
            int rows = 0;
            using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["IYFD"].ToString()))
            {
                connection.Open();
                using (SqlCommand cmd = new SqlCommand("dbo.UpsertTeam", connection))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    if(team.ID != null)
                        cmd.Parameters.AddWithValue("@ID", team.ID);
                    cmd.Parameters.AddWithValue("@name", team.Name);

                    rows = cmd.ExecuteNonQuery();
                }
            }
            return rows > 0;
        }