Exemplo n.º 1
0
        public string UpdateApi(string apiId, ApiDM apiDm)
        {
            string _returnedMsg = "";

            try
            {
                using (SqlConnection conn = GetConnection())
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand("UPDATE tApi SET fApiDesc = @ApiDesc WHERE fApiId = @ApiId", conn);
                    cmd.Parameters.AddWithValue("@ApiId", apiId);
                    cmd.Parameters.AddWithValue("@ApiDesc", apiDm.ApiDesc);
                    cmd.ExecuteNonQuery();
                    conn.Close();

                    _returnedMsg = "API Successfully Updated";
                }
            }
            catch (Exception e)
            {
                _returnedMsg = "Operation Failed!";
            }

            return(_returnedMsg);
        }
Exemplo n.º 2
0
        public string CreateApi(ApiDM apiDm)
        {
            string _returnedMsg = "";

            try
            {
                using (SqlConnection conn = GetConnection())
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand("INSERT INTO tApi(fApiId, fApiDesc) VALUES (@ApiId, @ApiDesc)", conn);
                    cmd.Parameters.AddWithValue("@ApiId", apiDm.ApiId);
                    cmd.Parameters.AddWithValue("@ApiDesc", apiDm.ApiDesc);
                    cmd.ExecuteNonQuery();
                    conn.Close();
                }

                _returnedMsg = "API Successfully Added";
            }
            catch (Exception e)
            {
                _returnedMsg = "Operation Failed!";
            }

            return(_returnedMsg);
        }