internal static void FillFromReader(Category category, SqlDataReader reader) { int colIndex = 0; int days = 0, seconds = 0; colIndex = reader.GetOrdinal(CN_CATEGORY_CREATION_DAY); if (!reader.IsDBNull(colIndex)) days = reader.GetInt32(colIndex); colIndex = reader.GetOrdinal(CN_CATEGORY_CREATION_SEC); if (!reader.IsDBNull(colIndex)) seconds = reader.GetInt32(colIndex); category.CreationDate = CMSCoreHelper.GetDateTime(days, seconds); colIndex = reader.GetOrdinal(CN_CATEGORY_DESCRIPTION); if (!reader.IsDBNull(colIndex)) category.Description = reader.GetString(colIndex); colIndex = reader.GetOrdinal(CN_CATEGORY_ID); if (!reader.IsDBNull(colIndex)) category.ID = reader.GetInt32(colIndex); colIndex = reader.GetOrdinal(CN_CATEGORY_IS_DELETED); if (!reader.IsDBNull(colIndex)) category.IsDeleted = reader.GetBoolean(colIndex); colIndex = reader.GetOrdinal(CN_CATEGORY_LANGUAGE_ID); if (!reader.IsDBNull(colIndex)) category.LanguageID = reader.GetInt32(colIndex); colIndex = reader.GetOrdinal(CN_CATEGORY_MODULE_ID); if (!reader.IsDBNull(colIndex)) category.ModuleID = reader.GetInt32(colIndex); colIndex = reader.GetOrdinal(CN_CATEGORY_NAME); if (!reader.IsDBNull(colIndex)) category.Name = reader.GetString(colIndex); colIndex = reader.GetOrdinal(CN_CATEGORY_PORTAL_ID); if (!reader.IsDBNull(colIndex)) category.PortalID = reader.GetInt32(colIndex); colIndex = reader.GetOrdinal(CN_CATEGORY_PARENT_ID); if (!reader.IsDBNull(colIndex)) category.ParentID = reader.GetInt32(colIndex); colIndex = reader.GetOrdinal(CN_CATEGORY_ORDER); if (!reader.IsDBNull(colIndex)) category.Order = reader.GetInt32(colIndex); colIndex = reader.GetOrdinal(CN_CATEGORY_CREATED_BY); if (!reader.IsDBNull(colIndex)) category.CreatedBy = reader.GetInt32(colIndex); colIndex = reader.GetOrdinal(CN_CATEGORY_IMAGE); if (!reader.IsDBNull(colIndex)) category.Image = reader.GetString(colIndex); }
internal static Category GetCategory(List<Category> categorys, SqlDataReader reader) { int colIndex = 0; colIndex = reader.GetOrdinal(CN_CATEGORY_ID); int value = reader.GetInt32(colIndex); Category category = categorys.Where(c => c.ID == value).FirstOrDefault(); if (category == null) { category = new Category(); categorys.Add(category); } return category; }
public static int Add(Category category) { return CategoryDataMapper.Add(category); }
internal static Category GetCategoryById(int CategoryID) { Category category = null; using (SqlConnection sqlConnection = new SqlConnection(CMSCoreBase.CMSCoreConnectionString)) { SqlCommand sqlCommand = new SqlCommand(SN_CATEGORY_GET_BY_ID, sqlConnection); sqlCommand.CommandType = System.Data.CommandType.StoredProcedure; SqlParameter parameter = new SqlParameter(PN_CATEGORY_ID, System.Data.SqlDbType.Int); parameter.Direction = System.Data.ParameterDirection.Input; parameter.Value = CategoryID; sqlCommand.Parameters.Add(parameter); sqlCommand.Connection.Open(); using (SqlDataReader reader = sqlCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)) { while (reader.Read()) { if (category == null) category = new Category(); FillFromReader(category, reader); } reader.Close(); sqlCommand.Connection.Close(); } } return category; }
public static void Update(Category category) { CategoryDataMapper.Update(category); }