public int Add(CMSPage obj)
        {
            _connection.ConnectionString = _ConnectionString;
            _command.Connection = _connection;
            _command.CommandType = CommandType.StoredProcedure;
            _command.CommandText = INSERTCMSPage;

            #region [Parameters]
            SqlParameter parameterID = new SqlParameter(PN_ID, SqlDbType.Int);
            parameterID.Value = obj.ID;
            parameterID.Direction = ParameterDirection.Output;
            _command.Parameters.Add(parameterID);
            SqlParameter parameterName = new SqlParameter(PN_NAME, SqlDbType.NVarChar);
            parameterName.Value = obj.Name;
            parameterName.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterName);
            SqlParameter parameterDescription = new SqlParameter(PN_DESCRIPTION, SqlDbType.NVarChar);
            parameterDescription.Value = obj.Description;
            parameterDescription.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterDescription);
            SqlParameter parameterKeyword = new SqlParameter(PN_KEYWORD, SqlDbType.NVarChar);
            parameterKeyword.Value = obj.Keyword;
            parameterKeyword.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterKeyword);
            SqlParameter parameterMetTags = new SqlParameter(PN_METTAGS, SqlDbType.NVarChar);
            parameterMetTags.Value = obj.MetTags;
            parameterMetTags.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterMetTags);

            SqlParameter parameterTemplateName = new SqlParameter(PN_TEMPLATENAME, SqlDbType.NVarChar);
            parameterTemplateName.Value = obj.TemplateName;
            parameterTemplateName.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterTemplateName);

            SqlParameter parameterType = new SqlParameter(PN_TYPE, SqlDbType.Int);
            parameterType.Value = obj.Type;
            parameterType.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterType);

            SqlParameter pageContent = new SqlParameter(PN_PAGE_CONTENT, SqlDbType.NVarChar);
            pageContent.Value = obj.PageContent;
            pageContent.Direction = ParameterDirection.Input;
            _command.Parameters.Add(pageContent); 
            #endregion;

            _connection.Open();
            _command.ExecuteNonQuery();
            _connection.Close();
            obj.ID = Convert.ToInt32(parameterID.Value);
            return obj.ID;
        }
 private void DeletePageforUpdate(CMSPage _page)
 {
     try
     {
         File.Delete(Server.MapPath("~/UserPages/" + _page.Name));
     }
     catch (Exception ex)
     {
         dvProblems.InnerText = ex.ToString();
     }
 }
        private void WriteNewPage(CMSPage _page)
        {
            //Read Sample File
            string samplepagecontent = UtilitiesManager.ReadFile(Server.MapPath("~/UserPages/SamplePage.txt"));
            samplepagecontent = samplepagecontent.Replace("#TemplateName#", _page.TemplateName);

            UtilitiesManager.WriteFile(Server.MapPath("~/UserPages/" + _page.Name), samplepagecontent, false, false);

        }
        private void EditMode()
        {
            if (ObjectID > 0)
            {
                CMSPage page = new CMSPage();
                page = CMSPageManager.GetByID(ObjectID);
                if (null == page)
                    return;

                txtName.Text = page.Name;
                txtMetaTags.Text = page.MetTags;
                txtKeywords.Text = page.Keyword;
                txtDesc.Text = page.Description;
                ddlTemplateName.SelectedValue = page.TemplateName;
                plcControls.Visible = true;
            }
        }
        void btnSaveUpdate_Click(object sender, EventArgs e)
        {

            CMSPage page = new CMSPage();
            if (ObjectID <= 0)
            {
                try
                {
                    page.Name = txtName.Text;
                    if (!page.Name.Contains(".aspx"))
                    {
                        page.Name += ".aspx";
                    }
                    page.Description = txtDesc.Text;
                    page.Keyword = txtKeywords.Text;
                    page.MetTags = txtMetaTags.Text;
                    page.TemplateName = ddlTemplateName.SelectedValue;
                    page.Type = DataLayer.Enums.RootEnums.PageType.User;
                    page.PageContent = string.Empty;
                    DeletePageforUpdate(page);
                    WriteNewPage(page);
                    CMSPageManager.Add(page);
                    AddMode();
                    dvProblems.InnerText = "Saved Successfully";
                }
                catch (Exception ex)
                {
                    dvProblems.InnerText = ex.ToString();
                }

            }
            else
            {
                try
                {
                    page = CMSPageManager.GetByID(ObjectID);
                    if (null == page)
                    {
                        dvProblems.InnerText = Resources.ExpressCMS.ResourceManager.GetString(ConstantsManager.UnknowErronOccures);
                        return;
                    }
                    page.Name = txtName.Text;
                    if (!page.Name.Contains(".aspx"))
                    {
                        page.Name += ".aspx";
                    }
                    page.Description = txtDesc.Text;
                    page.Keyword = txtKeywords.Text;
                    page.TemplateName = ddlTemplateName.SelectedValue;
                    page.MetTags = txtMetaTags.Text;
                    page.Type = DataLayer.Enums.RootEnums.PageType.User;
                    page.PageContent = string.Empty;
                    DeletePageforUpdate(page);
                    WriteNewPage(page);
                    CMSPageManager.Update(page);
                    EditMode();
                    dvProblems.InnerText = "Saved Successfully";
                }
                catch (Exception ex)
                {
                    dvProblems.InnerText = ex.ToString();
                }
            }
            BindGrid();
        }
Exemple #6
0
 public void PopulateCMSPage(SqlDataReader _dtr, CMSPage obj)
 {
     int columnIndex = 0;
     columnIndex = _dtr.GetOrdinal(CMSPageDataMapper.CN_ID);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.ID = _dtr.GetInt32((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(CMSPageDataMapper.CN_NAME);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.Name = _dtr.GetString((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(CMSPageDataMapper.CN_DESCRIPTION);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.Description = _dtr.GetString((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(CMSPageDataMapper.CN_KEYWORD);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.Keyword = _dtr.GetString((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(CMSPageDataMapper.CN_METTAGS);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.MetTags = _dtr.GetString((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(CMSPageDataMapper.CN_TEMPLATENAME);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.TemplateName = _dtr.GetString((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(CMSPageDataMapper.CN_TYPE);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.Type = (TG.ExpressCMS.DataLayer.Enums.RootEnums.PageType)_dtr.GetInt32((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(CMSPageDataMapper.PN_PAGE_CONTENT);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.PageContent = _dtr.GetString((columnIndex));
     }
 }
Exemple #7
0
        public static void Update(CMSPage obj)
        {
            CMSPageDataMapper objCaller = new CMSPageDataMapper();

            objCaller.Update(obj);
        }
Exemple #8
0
        public static int Add(CMSPage obj)
        {
            CMSPageDataMapper objCaller = new CMSPageDataMapper();

            return objCaller.Add(obj);
        }
 public CMSPage GetCMSPage(SqlDataReader _dtr, IList<CMSPage> colobj)
 {
     CMSPage obj = colobj.Where(t => t.ID == Convert.ToInt32(_dtr[CN_ID].ToString())).SingleOrDefault();
     if (null == obj)
     {
         obj = new CMSPage();
         colobj.Add(obj);
     }
     return obj;
 }
Exemple #10
0
        public IList<CMSPage> GetAll()
        {

            CMSPage obj = null;

            IList<CMSPage> colobj = new List<CMSPage>();
            _connection.ConnectionString = _ConnectionString;
            _command.Connection = _connection;
            _command.CommandType = CommandType.StoredProcedure;
            _command.CommandText = SELECTALLCMSPage;

            _connection.Open();
            try
            {
                using (_dtreader = _command.ExecuteReader())
                {
                    if (_dtreader != null && _dtreader.HasRows)
                    {
                        obj = new CMSPage();
                        colobj = new List<CMSPage>();
                        while (_dtreader.Read())
                        {
                            obj = GetCMSPage(_dtreader, colobj);
                            GetEntityFromReader(_dtreader, obj);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {

                _dtreader.Close();
                _connection.Close();
            }

            return colobj;
        }
Exemple #11
0
 private void GetEntityFromReader(SqlDataReader _dtr, CMSPage obj)
 {
     PopulateCMSPage(_dtr, obj);
 }
Exemple #12
0
        public CMSPage GetByID(int ID)
        {

            CMSPage obj = null;
            _connection.ConnectionString = _ConnectionString;
            _command.Connection = _connection;
            _command.CommandType = CommandType.StoredProcedure;
            _command.CommandText = SELECTCMSPage;

            #region [Parameters]
            SqlParameter parameterID = new SqlParameter(CN_ID, SqlDbType.Int);
            parameterID.Value = ID;
            parameterID.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterID);
            #endregion;

            _connection.Open();
            try
            {
                using (_dtreader = _command.ExecuteReader())
                {
                    if (_dtreader != null && _dtreader.HasRows)
                    {
                        obj = new CMSPage();
                        if (_dtreader.Read())
                            GetEntityFromReader(_dtreader, obj);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {

                _dtreader.Close();
                _connection.Close();
            }

            return obj;
        }