/// <summary> /// Method for checking whether test is exist for particular date or not /// </summary> /// <param name="test"></param> /// <returns></returns> public string IsTestExist(AthletePerformanceTrackerAPI.BAL.Model.Test test) { try { long Count = 0; List <GetAllTest> lstGetAllTest = new List <GetAllTest>(); using (SqlConnection connection = new SqlConnection(this.conn)) { string sql = "IsTestExist"; using (SqlCommand command = new SqlCommand(sql, connection)) { command.CommandType = CommandType.StoredProcedure; connection.Open(); command.Parameters.Add("@TestMasterId", SqlDbType.BigInt).Value = test.TestMasterId; command.Parameters.Add("@Date", SqlDbType.DateTime).Value = test.Date; command.ExecuteNonQuery(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { Count = Convert.ToInt32(reader["TestCount"].ToString()); } connection.Close(); } } return((Count > 0) ? "exist" : "notfound"); } catch (Exception) { return("Failure"); } }
/// <summary> /// Method for creating test /// </summary> /// <param name="test"></param> /// <returns></returns> public string CreateTest(AthletePerformanceTrackerAPI.BAL.Model.Test test) { try { List <GetAllTest> lstGetAllTest = new List <GetAllTest>(); using (SqlConnection connection = new SqlConnection(this.conn)) { string sql = "CreateTest"; using (SqlCommand command = new SqlCommand(sql, connection)) { command.CommandType = CommandType.StoredProcedure; connection.Open(); command.Parameters.Add("@TestMasterId", SqlDbType.Int).Value = test.TestMasterId; command.Parameters.Add("@Date", SqlDbType.DateTime).Value = test.Date; command.ExecuteNonQuery(); connection.Close(); } } return("Success"); } catch (Exception ex) { return("Failure"); } }