Editor.Services.PubblicazioneTempoServices.SetPubblicazioneTempo C# (CSharp) Method

SetPubblicazioneTempo() public method

public SetPubblicazioneTempo ( int contentID, string date, int active ) : bool
contentID int
date string
active int
return bool
        public bool SetPubblicazioneTempo(int contentID, string date, int active)
        {
            using (ISession session = HibernateHelper.GetSession().OpenSession()) {
                using (ITransaction transaction = session.BeginTransaction()) {
                    try {
                        string strSQL = "CONTENTID = " + contentID;
                        List<Content> contents = HibernateHelper.SelectCommand<Content>(session, strSQL);
                        Content content = null;
                        if (contents.Count > 0) {
                            content = contents[0];
                        } else {
                            throw new Exception("Impossibile trovare il content");
                        }

                        content.Date_publish = date;
                        content.Publish_active = active;
                        HibernateHelper.UpdateCommand(session, content);
                        transaction.Commit();
                        return true;

                    } catch (Exception ex) {
                        throw ex;
                    } finally {
                        session.Flush();
                        session.Close();
                    }
                }
            }
        }
PubblicazioneTempoServices