public static int GetSnapsCount(int id)
{
try
{
const string sql = "Select SnapsCount FROM Timelapses WHERE Id=@Id AND IsDeleted=0";
var p1 = new SqlParameter("@Id", id);
var cmd = new SqlCommand { CommandText = sql, CommandType = CommandType.Text };
cmd.Parameters.Add(p1);
cmd.Connection = Connection.DbConnection;
Connection.OpenConnection();
int count = (int)cmd.ExecuteScalar();
Connection.CloseConnection();
return count;
}
catch (Exception ex)
{
if (Connection.DbConnection.State == ConnectionState.Closed)
Utils.FileLog("TimelapseDao GetSnapsCount(int id) " + ex.Message);
else
Utils.FileLog(string.Format("TimelapseDao GetSnapsCount(int id) Id={0}<br />{1}", id, ex.Message));
return 0;
}
finally
{
Connection.CloseConnection();
}
}