/// <summary> /// Gets a category template /// </summary> /// <param name="CategoryTemplateID">Category template identifier</param> /// <returns>A category template</returns> public static CategoryTemplate GetCategoryTemplateByID(int CategoryTemplateID) { if (CategoryTemplateID == 0) { return(null); } string key = string.Format(CATEGORYTEMPLATES_BY_ID_KEY, CategoryTemplateID); object obj2 = NopCache.Get(key); if (TemplateManager.CacheEnabled && (obj2 != null)) { return((CategoryTemplate)obj2); } DBCategoryTemplate dbItem = DBProviderManager <DBTemplateProvider> .Provider.GetCategoryTemplateByID(CategoryTemplateID); CategoryTemplate categoryTemplate = DBMapping(dbItem); if (TemplateManager.CacheEnabled) { NopCache.Max(key, categoryTemplate); } return(categoryTemplate); }
private DBCategoryTemplate GetCategoryTemplateFromReader(IDataReader dataReader) { DBCategoryTemplate categoryTemplate = new DBCategoryTemplate(); categoryTemplate.CategoryTemplateID = NopSqlDataHelper.GetInt(dataReader, "CategoryTemplateID"); categoryTemplate.Name = NopSqlDataHelper.GetString(dataReader, "Name"); categoryTemplate.TemplatePath = NopSqlDataHelper.GetString(dataReader, "TemplatePath"); categoryTemplate.DisplayOrder = NopSqlDataHelper.GetInt(dataReader, "DisplayOrder"); categoryTemplate.CreatedOn = NopSqlDataHelper.GetUtcDateTime(dataReader, "CreatedOn"); categoryTemplate.UpdatedOn = NopSqlDataHelper.GetUtcDateTime(dataReader, "UpdatedOn"); return categoryTemplate; }
private static CategoryTemplate DBMapping(DBCategoryTemplate dbItem) { if (dbItem == null) { return(null); } var item = new CategoryTemplate(); item.CategoryTemplateId = dbItem.CategoryTemplateId; item.Name = dbItem.Name; item.TemplatePath = dbItem.TemplatePath; item.DisplayOrder = dbItem.DisplayOrder; item.CreatedOn = dbItem.CreatedOn; item.UpdatedOn = dbItem.UpdatedOn; return(item); }
/// <summary> /// Updates the category template /// </summary> /// <param name="CategoryTemplateID">Category template identifier</param> /// <param name="Name">The name</param> /// <param name="TemplatePath">The template path</param> /// <param name="DisplayOrder">The display order</param> /// <param name="CreatedOn">The date and time of instance creation</param> /// <param name="UpdatedOn">The date and time of instance update</param> /// <returns>A category template</returns> public static CategoryTemplate UpdateCategoryTemplate(int CategoryTemplateID, string Name, string TemplatePath, int DisplayOrder, DateTime CreatedOn, DateTime UpdatedOn) { CreatedOn = DateTimeHelper.ConvertToUtcTime(CreatedOn); UpdatedOn = DateTimeHelper.ConvertToUtcTime(UpdatedOn); DBCategoryTemplate dbItem = DBProviderManager <DBTemplateProvider> .Provider.UpdateCategoryTemplate(CategoryTemplateID, Name, TemplatePath, DisplayOrder, CreatedOn, UpdatedOn); CategoryTemplate categoryTemplate = DBMapping(dbItem); if (TemplateManager.CacheEnabled) { NopCache.RemoveByPattern(CATEGORYTEMPLATES_PATTERN_KEY); } return(categoryTemplate); }