public static int Add(Publish publish) { if (publish.PublishType == CMSEnums.PublishType.PublishNow) { publish.FromDate = DateTime.Now; publish.ToDate = DateTime.Now.AddYears(100); } return PublishDataMapper.Add(publish); }
private Publish PrepareNewPublish(int articleID) { Publish publish = new Publish { CreatedBy = CMSContext.CurrentUserID, LanguageID = CMSContext.LanguageID, ModuleID = AJH.CMS.Core.Enums.CMSEnums.Modules.Article, ObjectID = articleID, PortalID = CMSContext.PortalID, PublishType = CMSEnums.PublishType.PublishNow, }; return publish; }
public static void Update(Publish publish) { PublishDataMapper.Update(publish); }
internal static void FillFromReader(Publish publish, SqlDataReader reader) { int colIndex = 0; colIndex = reader.GetOrdinal(CN_PUBLISH_CREATED_BY); if (!reader.IsDBNull(colIndex)) publish.CreatedBy = reader.GetInt32(colIndex); int days = 0, seconds = 0; colIndex = reader.GetOrdinal(CN_PUBLISH_FROM_DAY); if (!reader.IsDBNull(colIndex)) days = reader.GetInt32(colIndex); colIndex = reader.GetOrdinal(CN_PUBLISH_FROM_SEC); if (!reader.IsDBNull(colIndex)) seconds = reader.GetInt32(colIndex); publish.FromDate = CMSCoreHelper.GetDateTime(days, seconds); colIndex = reader.GetOrdinal(CN_PUBLISH_ID); if (!reader.IsDBNull(colIndex)) publish.ID = reader.GetInt32(colIndex); colIndex = reader.GetOrdinal(CN_PUBLISH_LANGUAGE_ID); if (!reader.IsDBNull(colIndex)) publish.LanguageID = reader.GetInt32(colIndex); colIndex = reader.GetOrdinal(CN_PUBLISH_MODULE_ID); if (!reader.IsDBNull(colIndex)) publish.ModuleID = (AJH.CMS.Core.Enums.CMSEnums.Modules)reader.GetInt32(colIndex); colIndex = reader.GetOrdinal(CN_PUBLISH_OBJECT_ID); if (!reader.IsDBNull(colIndex)) publish.ObjectID = reader.GetInt32(colIndex); colIndex = reader.GetOrdinal(CN_PUBLISH_PORTAL_ID); if (!reader.IsDBNull(colIndex)) publish.PortalID = reader.GetInt32(colIndex); colIndex = reader.GetOrdinal(CN_PUBLISH_TO_DAY); if (!reader.IsDBNull(colIndex)) days = reader.GetInt32(colIndex); colIndex = reader.GetOrdinal(CN_PUBLISH_TO_SEC); if (!reader.IsDBNull(colIndex)) seconds = reader.GetInt32(colIndex); publish.ToDate = CMSCoreHelper.GetDateTime(days, seconds); colIndex = reader.GetOrdinal(CN_PUBLISH_TYPE_ID); if (!reader.IsDBNull(colIndex)) publish.PublishType = (CMSEnums.PublishType)reader.GetInt32(colIndex); }
internal static Publish GetPublish(List<Publish> publishs, SqlDataReader reader) { int colIndex = 0; colIndex = reader.GetOrdinal(CN_PUBLISH_ID); int value = reader.GetInt32(colIndex); Publish publish = publishs.Where(c => c.ID == value).FirstOrDefault(); if (publish == null) { publish = new Publish(); publishs.Add(publish); } return publish; }
internal static Publish GetPublishById(int PublishID) { Publish publish = null; using (SqlConnection sqlConnection = new SqlConnection(CMSCoreBase.CMSCoreConnectionString)) { SqlCommand sqlCommand = new SqlCommand(SN_PUBLISH_GET_BY_ID, sqlConnection); sqlCommand.CommandType = System.Data.CommandType.StoredProcedure; SqlParameter parameter = new SqlParameter(PN_PUBLISH_ID, System.Data.SqlDbType.Int); parameter.Direction = System.Data.ParameterDirection.Input; parameter.Value = PublishID; sqlCommand.Parameters.Add(parameter); sqlCommand.Connection.Open(); using (SqlDataReader reader = sqlCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)) { while (reader.Read()) { if (publish == null) publish = new Publish(); FillFromReader(publish, reader); } reader.Close(); sqlCommand.Connection.Close(); } } return publish; }
private Publish PrepareNewPublish(int menuID) { Publish publish = new Publish { CreatedBy = CMSContext.CurrentUserID, FromDate = DateTime.Now, ToDate = DateTime.Now, LanguageID = CMSContext.LanguageID, ModuleID = AJH.CMS.Core.Enums.CMSEnums.Modules.Menu, ObjectID = menuID, PortalID = CMSContext.PortalID, PublishType = CMSEnums.PublishType.PublishNow, }; return publish; }