public static Common.Models.External.ExternalSession Create(Common.Models.External.ExternalSession model) { model.Id = Guid.NewGuid(); model.Created = DateTime.UtcNow; model.Timeout = 15 * 60; // 15 minutes model.Expires = model.Created.AddSeconds(model.Timeout); DBOs.External.ExternalSession dbo = Mapper.Map <DBOs.External.ExternalSession>(model); using (IDbConnection conn = Database.Instance.GetConnection()) { conn.Execute("INSERT INTO \"external_session\" (\"id\", \"user_pid\", \"app_name\", \"utc_created\", \"utc_expires\", \"timeout\", \"machine_id\") " + "VALUES (@Id, @UserPId, @AppName, @UtcCreated, @UtcExpires, @Timeout, @MachineId)", dbo); } return(model); }
public static Common.Models.External.ExternalSession Create( Common.Models.External.ExternalSession model, IDbConnection conn = null, bool closeConnection = true) { model.Id = Guid.NewGuid(); model.Created = DateTime.UtcNow; model.Timeout = 15 * 60; // 15 minutes model.Expires = model.Created.AddSeconds(model.Timeout); DBOs.External.ExternalSession dbo = Mapper.Map <DBOs.External.ExternalSession>(model); conn = DataHelper.OpenIfNeeded(conn); conn.Execute("INSERT INTO \"external_session\" (\"id\", \"user_pid\", \"app_name\", \"utc_created\", \"utc_expires\", \"timeout\", \"machine_id\") " + "VALUES (@Id, @UserPId, @AppName, @UtcCreated, @UtcExpires, @Timeout, @MachineId)", dbo); DataHelper.Close(conn, closeConnection); return(model); }