void btnSaveUpdate_Click(object sender, EventArgs e) { NewsItem newsItems = new NewsItem(); int ordernumber = 0; Int32.TryParse(txtOrderNumber.Text, out ordernumber); if (ObjectID <= 0) { try { newsItems.Name = txtName.Text.Replace(":", "").Replace("=", ""); newsItems.Description = txtDesc.Text; newsItems.IsFeatured = chkIsFeatured.Checked; newsItems.Details = txtDetails.Text; newsItems.CategoryID = Convert.ToInt32(ddlCategories.SelectedValue); newsItems.Url = ""; newsItems.LangID = 0; newsItems.CreationDate = UtilitiesManager.GetFormattedDate(); newsItems.Date = UtilitiesManager.GetFormattedDate(dtDate.SelectedDate.Value); newsItems.CreationTime = UtilitiesManager.GetFormattedTime(); newsItems.CreatedBy = SecurityContext.LoggedInUser.ID; newsItems.IsDeleted = false; newsItems.OrderNumber = ordernumber; int mappedlangID = 0; Int32.TryParse(ddlMappedLanguageID.SelectedValue, out mappedlangID); newsItems.RefLangID = mappedlangID; string guid = Guid.NewGuid().ToString().Replace("-", ""); newsItems.Guid = guid.Substring(0, 8); newsItems.Image = UtilitiesManager.GetSavedFile(fUploader, true, true); newsItems.URlType = (TG.ExpressCMS.DataLayer.Enums.RootEnums.NewsItemURLType)Convert.ToInt32(ddlNewsType.SelectedValue); if (rdblater.Checked) { newsItems.PublishFrom = UtilitiesManager.GetFormattedDate(txtPublishFrom.SelectedDate.Value); newsItems.PublishTo = UtilitiesManager.GetFormattedDate(txtDateTo.SelectedDate.Value); } else if (rdbNow.Checked) { newsItems.PublishFrom = new DateTime(1993, 1, 1).ToString("dd/MM/yyyy"); newsItems.PublishTo = new DateTime(1992, 1, 1).ToString("dd/MM/yyyy"); } else { newsItems.PublishFrom = new DateTime(1993, 1, 1).ToString("dd/MM/yyyy"); newsItems.PublishTo = new DateTime(1994, 1, 1).ToString("dd/MM/yyyy"); } newsItems.ShowComments = chkShowComments.Checked; if (newsItems.URlType == RootEnums.NewsItemURLType.External) newsItems.Url = txtURL.Text; string keywords = ""; for (int i = 0; i < chklstkeywrds.Items.Count; i++) { if (chklstkeywrds.Items[i].Selected) keywords += chklstkeywrds.Items[i].Text; } newsItems.Keywords = keywords.Replace("ال", "").Replace(".", ""); NewsItemManager.Add(newsItems); if (newsItems.URlType == RootEnums.NewsItemURLType.Internal) { newsItems.Url = ResolveUrl(ExpressoConfig.NewsConfigElement.GetDefaultDetailsPage) + ConstantsManager.NewsID + "=" + newsItems.ID; NewsItemManager.Update(newsItems); } AddMode(); dvProblems.InnerText = "Saved Successfully"; } catch (Exception ex) { dvProblems.InnerText = ex.ToString(); } } else { try { newsItems = NewsItemManager.GetByID(ObjectID); if (null == newsItems) { dvProblems.InnerText = Resources.ExpressCMS.ResourceManager.GetString(ConstantsManager.UnknowErronOccures); return; } newsItems.Name = txtName.Text; newsItems.Description = txtDesc.Text; newsItems.Details = txtDetails.Text; newsItems.CategoryID = Convert.ToInt32(ddlCategories.SelectedValue); newsItems.IsFeatured = chkIsFeatured.Checked; newsItems.Guid = newsItems.Guid; newsItems.OrderNumber = ordernumber; newsItems.IsDeleted = false; int mappedlangID = 0; Int32.TryParse(ddlMappedLanguageID.SelectedValue, out mappedlangID); newsItems.RefLangID = mappedlangID; if (chkUpdateImage.Checked) newsItems.Image = UtilitiesManager.GetSavedFile(fUploader, true, true); newsItems.URlType = (TG.ExpressCMS.DataLayer.Enums.RootEnums.NewsItemURLType)Convert.ToInt32(ddlNewsType.SelectedValue); if (rdblater.Checked) { newsItems.PublishFrom = UtilitiesManager.GetFormattedDate(txtPublishFrom.SelectedDate.Value); newsItems.PublishTo = UtilitiesManager.GetFormattedDate(txtDateTo.SelectedDate.Value); } else if (rdbNow.Checked) { newsItems.PublishFrom = new DateTime(1993, 1, 1).ToString("dd/MM/yyyy"); newsItems.PublishTo = new DateTime(1992, 1, 1).ToString("dd/MM/yyyy"); } else { newsItems.PublishFrom = new DateTime(1993, 1, 1).ToString("dd/MM/yyyy"); newsItems.PublishTo = new DateTime(1994, 1, 1).ToString("dd/MM/yyyy"); } newsItems.Date = UtilitiesManager.GetFormattedDate(dtDate.SelectedDate.Value); newsItems.ShowComments = chkShowComments.Checked; if (newsItems.URlType == RootEnums.NewsItemURLType.Internal) { newsItems.Url = ResolveUrl(ExpressoConfig.NewsConfigElement.GetDefaultDetailsPage) + ConstantsManager.NewsID + "=" + newsItems.ID; } else newsItems.Url = txtURL.Text; string keywords = ""; for (int i = 0; i < chklstkeywrds.Items.Count; i++) { if (chklstkeywrds.Items[i].Selected) keywords += chklstkeywrds.Items[i].Text; } newsItems.Keywords = keywords.Replace("ال", "").Replace(".", ""); NewsItemManager.Update(newsItems); EditMode(); dvProblems.InnerText = "Saved Successfully"; upnlGrid.Update(); } catch (Exception ex) { dvProblems.InnerText = ex.ToString(); } } BindGrid(10); //RSSUpdater updater = new RSSUpdater(); //updater.UpdateCategoryFile(newsItems.CategoryID); }
private void EditMode() { if (ObjectID > 0) { imguploaded.Visible = true; chkUpdateImage.Checked = false; NewsItem newsItems = new NewsItem(); newsItems = NewsItemManager.GetByID(ObjectID); if (null == newsItems) return; chkIsFeatured.Checked = newsItems.IsFeatured; txtOrderNumber.Text = newsItems.OrderNumber.ToString(); txtPublishFrom.DbSelectedDate = newsItems.PublishFrom; if (newsItems.RefLangID != 0) ddlMappedLanguageID.SelectedValue = newsItems.RefLangID.ToString(); txtDateTo.DbSelectedDate = newsItems.PublishTo; txtDesc.Text = newsItems.Description; txtDetails.Text = newsItems.Details; txtName.Text = newsItems.Name; chkUpdateImage.Visible = true; dtDate.DbSelectedDate = newsItems.Date; txtURL.Text = newsItems.Url; chkShowComments.Checked = newsItems.ShowComments; ddlNewsType.SelectedValue = Convert.ToInt32(newsItems.URlType).ToString(); ddlCategories.SelectedValue = newsItems.CategoryID.ToString(); plcControls.Visible = true; if (newsItems.URlType == RootEnums.NewsItemURLType.External) { rfvURL.Enabled = true; trdetails.Visible = false; } else { rfvURL.Enabled = false; trdetails.Visible = true; } if (UtilitiesManager.GetFormattedDateasDate(newsItems.PublishTo) < UtilitiesManager.GetFormattedDateasDate(newsItems.PublishFrom)) { trDatesto.Visible = false; trDatesFrom.Visible = false; rdbNow.Checked = true; rdblater.Checked = false; rdbUnpublish.Checked = false; } else if (UtilitiesManager.GetFormattedDateasDate(newsItems.PublishTo) > UtilitiesManager.GetFormattedDateasDate(newsItems.PublishFrom) && UtilitiesManager.GetFormattedDateasDate(newsItems.PublishTo) <= UtilitiesManager.GetFormattedDateasDate(DateTime.Now.ToShortDateString())) { rdbUnpublish.Checked = true; trDatesto.Visible = false; trDatesFrom.Visible = false; rdbNow.Checked = true; rdblater.Checked = false; } else { rdbUnpublish.Checked = false; trDatesto.Visible = true; trDatesFrom.Visible = true; rdbNow.Checked = false; rdblater.Checked = true; } imguploaded.ImageUrl = GetArticleImage(newsItems.Image); chklstkeywrds.DataSource = ""; chklstkeywrds.DataBind(); trURL.Visible = true; } }
public IList<NewsItem> GetAlLBySearchAndPaging(int from, int to, ref int totalRows, string keyword) { NewsItem obj = new NewsItem(); IList<NewsItem> colobj = new List<NewsItem>(); _connection.ConnectionString = _ConnectionString; _command.Connection = _connection; _command.CommandType = CommandType.StoredProcedure; _command.CommandText = "[dbo].[SelectAllBySearchAndPaging]"; #region [Parameters] SqlParameter pfrom = new SqlParameter("From", SqlDbType.Int); pfrom.Value = from; pfrom.Direction = ParameterDirection.Input; _command.Parameters.Add(pfrom); SqlParameter pTo = new SqlParameter("To", SqlDbType.Int); pTo.Value = to; pTo.Direction = ParameterDirection.Input; _command.Parameters.Add(pTo); SqlParameter pKey = new SqlParameter("Keyword", SqlDbType.NVarChar); pKey.Value = keyword; pKey.Direction = ParameterDirection.Input; _command.Parameters.Add(pKey); SqlParameter ptotalRows = new SqlParameter("TotalRows", SqlDbType.Int); ptotalRows.Value = totalRows; ptotalRows.Direction = ParameterDirection.Output; _command.Parameters.Add(ptotalRows); #endregion; _connection.Open(); try { using (_dtreader = _command.ExecuteReader()) { if (_dtreader != null && _dtreader.HasRows) { colobj = new List<NewsItem>(); while (_dtreader.Read()) { obj = GetNewsItem(_dtreader, colobj); GetEntityFromReader(_dtreader, obj); } } } } catch (Exception ex) { throw ex; } finally { totalRows = Convert.ToInt32(ptotalRows.Value); _dtreader.Close(); _connection.Close(); } return colobj; }
public void PopulateNewsItem(SqlDataReader _dtr, NewsItem obj) { int columnIndex = 0; columnIndex = _dtr.GetOrdinal(NewsItemDataMapper.CN_ID); if (!_dtr.IsDBNull(columnIndex)) { obj.ID = _dtr.GetInt32((columnIndex)); } columnIndex = _dtr.GetOrdinal(NewsItemDataMapper.CN_NAME); if (!_dtr.IsDBNull(columnIndex)) { obj.Name = _dtr.GetString((columnIndex)); } columnIndex = _dtr.GetOrdinal(NewsItemDataMapper.CN_DESCRIPTION); if (!_dtr.IsDBNull(columnIndex)) { obj.Description = _dtr.GetString((columnIndex)); } columnIndex = _dtr.GetOrdinal(NewsItemDataMapper.CN_DETAILS); if (!_dtr.IsDBNull(columnIndex)) { obj.Details = _dtr.GetString((columnIndex)); } columnIndex = _dtr.GetOrdinal(NewsItemDataMapper.CN_TYPE); if (!_dtr.IsDBNull(columnIndex)) { obj.URlType = (TG.ExpressCMS.DataLayer.Enums.RootEnums.NewsItemURLType)_dtr.GetInt32((columnIndex)); } columnIndex = _dtr.GetOrdinal(NewsItemDataMapper.CN_CATEGORYID); if (!_dtr.IsDBNull(columnIndex)) { obj.CategoryID = _dtr.GetInt32((columnIndex)); } columnIndex = _dtr.GetOrdinal(NewsItemDataMapper.CN_URL); if (!_dtr.IsDBNull(columnIndex)) { obj.Url = _dtr.GetString((columnIndex)); } columnIndex = _dtr.GetOrdinal(NewsItemDataMapper.CN_IMAGE); if (!_dtr.IsDBNull(columnIndex)) { obj.Image = _dtr.GetString((columnIndex)); } columnIndex = _dtr.GetOrdinal(NewsItemDataMapper.CN_CREATIONDATE); if (!_dtr.IsDBNull(columnIndex)) { obj.CreationDate = _dtr.GetString((columnIndex)); } columnIndex = _dtr.GetOrdinal(NewsItemDataMapper.CN_CREATEDBY); if (!_dtr.IsDBNull(columnIndex)) { obj.CreatedBy = Convert.ToInt32(_dtr.GetString((columnIndex))); } columnIndex = _dtr.GetOrdinal(NewsItemDataMapper.CN_CREATIONTIME); if (!_dtr.IsDBNull(columnIndex)) { obj.CreationTime = _dtr.GetString((columnIndex)); } columnIndex = _dtr.GetOrdinal(NewsItemDataMapper.CN_PUBLISHFROM); if (!_dtr.IsDBNull(columnIndex)) { obj.PublishFrom = _dtr.GetString((columnIndex)); } columnIndex = _dtr.GetOrdinal(NewsItemDataMapper.CN_PUBLISHTO); if (!_dtr.IsDBNull(columnIndex)) { obj.PublishTo = _dtr.GetString((columnIndex)); } columnIndex = _dtr.GetOrdinal(NewsItemDataMapper.CN_ISDELETED); if (!_dtr.IsDBNull(columnIndex)) { obj.IsDeleted = _dtr.GetBoolean((columnIndex)); } columnIndex = _dtr.GetOrdinal(NewsItemDataMapper.CN_ShowComments); if (!_dtr.IsDBNull(columnIndex)) { obj.ShowComments = _dtr.GetBoolean((columnIndex)); } columnIndex = _dtr.GetOrdinal(NewsItemDataMapper.CN_LANG_ID); if (!_dtr.IsDBNull(columnIndex)) { obj.LangID = _dtr.GetInt32((columnIndex)); } columnIndex = _dtr.GetOrdinal(NewsItemDataMapper.CN_DATE); if (!_dtr.IsDBNull(columnIndex)) { obj.Date = _dtr.GetString((columnIndex)); } columnIndex = _dtr.GetOrdinal(NewsItemDataMapper.CN_OrderNumber); if (!_dtr.IsDBNull(columnIndex)) { obj.OrderNumber = _dtr.GetInt32((columnIndex)); } columnIndex = _dtr.GetOrdinal(NewsItemDataMapper.PN_REF_LANG_ID); if (!_dtr.IsDBNull(columnIndex)) { obj.RefLangID = _dtr.GetInt32((columnIndex)); } columnIndex = _dtr.GetOrdinal(NewsItemDataMapper.CN_VIEW_COUNT); if (!_dtr.IsDBNull(columnIndex)) { obj.ViewCount = _dtr.GetInt32((columnIndex)); } columnIndex = _dtr.GetOrdinal(NewsItemDataMapper.CN_IS_FEATURED); if (!_dtr.IsDBNull(columnIndex)) { obj.IsFeatured = _dtr.GetBoolean((columnIndex)); } columnIndex = _dtr.GetOrdinal(NewsItemDataMapper.CN_KEYWORDS); if (!_dtr.IsDBNull(columnIndex)) { obj.Keywords = _dtr.GetString((columnIndex)); } columnIndex = _dtr.GetOrdinal(NewsItemDataMapper.CN_GUID); if (!_dtr.IsDBNull(columnIndex)) { obj.Guid = _dtr.GetString((columnIndex)); } }
public XmlDocument GetByCategoryIDAndUniqueYears(int CatID) { NewsItem obj = new NewsItem(); XmlDocument xDoc = new XmlDocument(); IList<NewsItem> colobj = new List<NewsItem>(); _connection.ConnectionString = _ConnectionString; _command.Connection = _connection; _command.CommandType = CommandType.StoredProcedure; _command.CommandText = "[usp_SelectNewsItemsByCategoryIDAndUniqueYears]"; #region [Parameters] SqlParameter parameterID = new SqlParameter(PN_CATEGORYID, SqlDbType.Int); parameterID.Value = CatID; parameterID.Direction = ParameterDirection.Input; _command.Parameters.Add(parameterID); #endregion; _connection.Open(); XmlReader _dxtreader = null; try { using (_dxtreader = _command.ExecuteXmlReader()) { if (_dxtreader != null) { _dxtreader.Read(); string xml = "<Data>"; while (_dxtreader.ReadState != ReadState.EndOfFile) { xml += _dxtreader.ReadOuterXml(); } xml = xml.Replace("dbo.", ""); xml += "</Data>"; xDoc.LoadXml(xml); } } } catch (Exception ex) { throw ex; } finally { _dxtreader.Close(); _connection.Close(); } return xDoc; }
public int Add(NewsItem obj) { _connection.ConnectionString = _ConnectionString; _command.Connection = _connection; _command.CommandType = CommandType.StoredProcedure; _command.CommandText = INSERTNewsItem; #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 parameterDetails = new SqlParameter(PN_DETAILS, SqlDbType.NVarChar); parameterDetails.Value = obj.Details; parameterDetails.Direction = ParameterDirection.Input; _command.Parameters.Add(parameterDetails); SqlParameter parameterType = new SqlParameter(PN_TYPE, SqlDbType.Int); parameterType.Value = Convert.ToInt32(obj.URlType); parameterType.Direction = ParameterDirection.Input; _command.Parameters.Add(parameterType); SqlParameter parameterCategoryID = new SqlParameter(PN_CATEGORYID, SqlDbType.Int); parameterCategoryID.Value = obj.CategoryID; parameterCategoryID.Direction = ParameterDirection.Input; _command.Parameters.Add(parameterCategoryID); SqlParameter parameterUrl = new SqlParameter(PN_URL, SqlDbType.NVarChar); parameterUrl.Value = obj.Url; parameterUrl.Direction = ParameterDirection.Input; _command.Parameters.Add(parameterUrl); SqlParameter parameterImage = new SqlParameter(PN_IMAGE, SqlDbType.NVarChar); parameterImage.Value = obj.Image; parameterImage.Direction = ParameterDirection.Input; _command.Parameters.Add(parameterImage); SqlParameter parameterCreationDate = new SqlParameter(PN_CREATIONDATE, SqlDbType.NVarChar); parameterCreationDate.Value = obj.CreationDate; parameterCreationDate.Direction = ParameterDirection.Input; _command.Parameters.Add(parameterCreationDate); SqlParameter parameterCreatedBy = new SqlParameter(PN_CREATEDBY, SqlDbType.Int); parameterCreatedBy.Value = obj.CreatedBy; parameterCreatedBy.Direction = ParameterDirection.Input; _command.Parameters.Add(parameterCreatedBy); SqlParameter parameterCreationTime = new SqlParameter(PN_CREATIONTIME, SqlDbType.NVarChar); parameterCreationTime.Value = obj.CreationTime; parameterCreationTime.Direction = ParameterDirection.Input; _command.Parameters.Add(parameterCreationTime); SqlParameter parameterPublishFrom = new SqlParameter(PN_PUBLISHFROM, SqlDbType.NVarChar); parameterPublishFrom.Value = obj.PublishFrom; parameterPublishFrom.Direction = ParameterDirection.Input; _command.Parameters.Add(parameterPublishFrom); SqlParameter parameterPublishTo = new SqlParameter(PN_PUBLISHTO, SqlDbType.NVarChar); parameterPublishTo.Value = obj.PublishTo; parameterPublishTo.Direction = ParameterDirection.Input; _command.Parameters.Add(parameterPublishTo); SqlParameter parameterIsDeleted = new SqlParameter(PN_ISDELETED, SqlDbType.Int); parameterIsDeleted.Value = obj.IsDeleted; parameterIsDeleted.Direction = ParameterDirection.Input; _command.Parameters.Add(parameterIsDeleted); SqlParameter parameterShowComments = new SqlParameter(PN_ShowComments, SqlDbType.Bit); parameterShowComments.Value = obj.ShowComments; parameterShowComments.Direction = ParameterDirection.Input; _command.Parameters.Add(parameterShowComments); SqlParameter paramLangId = new SqlParameter(PN_LANG_ID, SqlDbType.Int); paramLangId.Value = obj.LangID; paramLangId.Direction = ParameterDirection.Input; _command.Parameters.Add(paramLangId); SqlParameter pDate = new SqlParameter(PN_DATE, SqlDbType.NVarChar); pDate.Value = obj.Date; pDate.Direction = ParameterDirection.Input; _command.Parameters.Add(pDate); SqlParameter pOrderNumber = new SqlParameter(PN_OrderNumber, SqlDbType.Int); pOrderNumber.Value = obj.OrderNumber; pOrderNumber.Direction = ParameterDirection.Input; _command.Parameters.Add(pOrderNumber); SqlParameter pRefLangID = new SqlParameter(PN_REF_LANG_ID, SqlDbType.Int); pRefLangID.Value = obj.RefLangID; pRefLangID.Direction = ParameterDirection.Input; _command.Parameters.Add(pRefLangID); SqlParameter prefViewCount = new SqlParameter(PN_VIEW_COUNT, SqlDbType.Int); prefViewCount.Value = obj.ViewCount; prefViewCount.Direction = ParameterDirection.Input; _command.Parameters.Add(prefViewCount); SqlParameter prefIsFeatured = new SqlParameter(PN_IS_FEATURED, SqlDbType.Int); prefIsFeatured.Value = obj.IsFeatured; prefIsFeatured.Direction = ParameterDirection.Input; _command.Parameters.Add(prefIsFeatured); SqlParameter pkeywords = new SqlParameter(PN_KEYWORDS, SqlDbType.NVarChar); pkeywords.Value = obj.Keywords; pkeywords.Direction = ParameterDirection.Input; _command.Parameters.Add(pkeywords); SqlParameter pGUID = new SqlParameter(PN_GUID, SqlDbType.NVarChar); pGUID.Value = obj.Guid; pGUID.Direction = ParameterDirection.Input; _command.Parameters.Add(pGUID); #endregion; _connection.Open(); _command.ExecuteNonQuery(); _connection.Close(); obj.ID = Convert.ToInt32(parameterID.Value); return obj.ID; }
public IList<NewsItem> GetByLanguageIDandHash(string hash, int languageID) { NewsItem obj = new NewsItem(); IList<NewsItem> colobj = new List<NewsItem>(); _connection.ConnectionString = _ConnectionString; _command.Connection = _connection; _command.CommandType = CommandType.StoredProcedure; _command.CommandText = "usp_SelectNewsItemsByCategoryHashandLang"; #region [Parameters] SqlParameter paramhash = new SqlParameter(CategoryDataMapper.PN_HASH, SqlDbType.NVarChar); paramhash.Value = hash; paramhash.Direction = ParameterDirection.Input; _command.Parameters.Add(paramhash); SqlParameter paramLangID = new SqlParameter(CategoryDataMapper.PN_LANGUAGE_ID, SqlDbType.Int); paramLangID.Value = languageID; paramLangID.Direction = ParameterDirection.Input; _command.Parameters.Add(paramLangID); #endregion; _connection.Open(); try { using (_dtreader = _command.ExecuteReader()) { if (_dtreader != null && _dtreader.HasRows) { obj = new NewsItem(); colobj = new List<NewsItem>(); while (_dtreader.Read()) { obj = GetNewsItem(_dtreader, colobj); GetEntityFromReader(_dtreader, obj); } } } } catch (Exception ex) { throw ex; } finally { _dtreader.Close(); _connection.Close(); } return colobj; }
public IList<NewsItem> GetByCategoryID(int CatID) { NewsItem obj = new NewsItem(); IList<NewsItem> colobj = new List<NewsItem>(); _connection.ConnectionString = _ConnectionString; _command.Connection = _connection; _command.CommandType = CommandType.StoredProcedure; _command.CommandText = SELECTALLNewsItemByCategoryID; #region [Parameters] SqlParameter parameterID = new SqlParameter(PN_CATEGORYID, SqlDbType.Int); parameterID.Value = CatID; parameterID.Direction = ParameterDirection.Input; _command.Parameters.Add(parameterID); #endregion; _connection.Open(); try { using (_dtreader = _command.ExecuteReader()) { if (_dtreader != null && _dtreader.HasRows) { obj = new NewsItem(); colobj = new List<NewsItem>(); while (_dtreader.Read()) { obj = GetNewsItem(_dtreader, colobj); GetEntityFromReader(_dtreader, obj); } } } } catch (Exception ex) { throw ex; } finally { _dtreader.Close(); _connection.Close(); } return colobj; }
private void GetEntityFromReader(SqlDataReader _dtr, NewsItem obj) { PopulateNewsItem(_dtr, obj); }
public IList<NewsItem> GetAllForAnotherLang() { NewsItem obj = new NewsItem(); IList<NewsItem> colobj = new List<NewsItem>(); _connection.ConnectionString = ConfigManager.GetConnectionStringOfSecurity(); _command.Connection = _connection; _command.CommandType = CommandType.StoredProcedure; _command.CommandText = SELECTALLNewsItem; _connection.Open(); try { using (_dtreader = _command.ExecuteReader()) { if (_dtreader != null && _dtreader.HasRows) { obj = new NewsItem(); colobj = new List<NewsItem>(); while (_dtreader.Read()) { obj = GetNewsItem(_dtreader, colobj); GetEntityFromReader(_dtreader, obj); } } } } catch (Exception ex) { throw ex; } finally { _dtreader.Close(); _connection.Close(); } return colobj; }
public NewsItem GetByGUID(string guid) { NewsItem obj = null; _connection.ConnectionString = _ConnectionString; _command.Connection = _connection; _command.CommandType = CommandType.StoredProcedure; _command.CommandText = "SelectNewsbyGuid"; #region [Parameters] SqlParameter parameterID = new SqlParameter(PN_GUID, SqlDbType.NVarChar); parameterID.Value = guid; parameterID.Direction = ParameterDirection.Input; _command.Parameters.Add(parameterID); #endregion; _connection.Open(); try { using (_dtreader = _command.ExecuteReader()) { if (_dtreader != null && _dtreader.HasRows) { obj = new NewsItem(); if (_dtreader.Read()) GetEntityFromReader(_dtreader, obj); } } } catch (Exception ex) { throw ex; } finally { _dtreader.Close(); _connection.Close(); } return obj; }
public NewsItem GetNewsItem(SqlDataReader _dtr, IList<NewsItem> colobj) { NewsItem obj = colobj.Where(t => t.ID == Convert.ToInt32(_dtr[CN_ID].ToString())).SingleOrDefault(); if (null == obj) { obj = new NewsItem(); colobj.Add(obj); } return obj; }
public static string GetNewsURL(NewsItem newsItem) { if (null == newsItem) return "Err"; if (newsItem.URlType == DataLayer.Enums.RootEnums.NewsItemURLType.Internal) { return ConfigurationManager.AppSettings["DefNewsDetailsPage"] + "ND=" + newsItem.ID; } else { return newsItem.Url; } }
public static void Update(NewsItem obj) { NewsItemDataMapper objCaller = new NewsItemDataMapper(); objCaller.Update(obj); }
public static int Add(NewsItem obj) { NewsItemDataMapper objCaller = new NewsItemDataMapper(); return objCaller.Add(obj); }