public static Timelapse Get(int id)
{
var timelapse = new Timelapse();
try
{
const string sql = "Select * FROM Timelapses WHERE Id=@Id AND IsDeleted=0 ORDER BY CreatedDT DESC";
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();
var dr = GetListFromDataReader(cmd.ExecuteReader());
if (dr.Count > 0) timelapse = dr.FirstOrDefault();
Connection.CloseConnection();
return timelapse;
}
catch (Exception ex)
{
if (Connection.DbConnection.State == ConnectionState.Closed)
Utils.FileLog("TimelapseDao Get(int id) " + ex.Message);
else
Utils.FileLog(string.Format("TimelapseDao Get(int id) Id={0}<br />{1}", id, ex.Message));
return timelapse;
}
finally
{
Connection.CloseConnection();
}
}