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 DBCategoryTemplate GetCategoryTemplateFromReader(IDataReader dataReader) { var item = new DBCategoryTemplate(); item.CategoryTemplateId = NopSqlDataHelper.GetInt(dataReader, "CategoryTemplateID"); item.Name = NopSqlDataHelper.GetString(dataReader, "Name"); item.TemplatePath = NopSqlDataHelper.GetString(dataReader, "TemplatePath"); item.DisplayOrder = NopSqlDataHelper.GetInt(dataReader, "DisplayOrder"); item.CreatedOn = NopSqlDataHelper.GetUtcDateTime(dataReader, "CreatedOn"); item.UpdatedOn = NopSqlDataHelper.GetUtcDateTime(dataReader, "UpdatedOn"); return(item); }
/// <summary> /// Deletes a category template /// </summary> /// <param name="CategoryTemplateID">Category template identifier</param> public override void DeleteCategoryTemplate(int CategoryTemplateID) { Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DBCategoryTemplate categoryTemplate = GetCategoryTemplateByID(CategoryTemplateID); if (categoryTemplate != null) { DbCommand dbCommand = db.GetStoredProcCommand("Nop_CategoryTemplateDelete"); db.AddInParameter(dbCommand, "CategoryTemplateID", DbType.Int32, CategoryTemplateID); int retValue = db.ExecuteNonQuery(dbCommand); } }
/// <summary> /// Gets all category templates /// </summary> /// <returns>Category template collection</returns> public override DBCategoryTemplateCollection GetAllCategoryTemplates() { DBCategoryTemplateCollection categoryTemplateCollection = new DBCategoryTemplateCollection(); Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_CategoryTemplateLoadAll"); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { DBCategoryTemplate categoryTemplate = GetCategoryTemplateFromReader(dataReader); categoryTemplateCollection.Add(categoryTemplate); } } return(categoryTemplateCollection); }
/// <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 override DBCategoryTemplate UpdateCategoryTemplate(int categoryTemplateId, string name, string templatePath, int displayOrder, DateTime createdOn, DateTime updatedOn) { DBCategoryTemplate item = null; Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_CategoryTemplateUpdate"); db.AddInParameter(dbCommand, "CategoryTemplateID", DbType.Int32, categoryTemplateId); db.AddInParameter(dbCommand, "Name", DbType.String, name); db.AddInParameter(dbCommand, "TemplatePath", DbType.String, templatePath); db.AddInParameter(dbCommand, "DisplayOrder", DbType.Int32, displayOrder); db.AddInParameter(dbCommand, "CreatedOn", DbType.DateTime, createdOn); db.AddInParameter(dbCommand, "UpdatedOn", DbType.DateTime, updatedOn); if (db.ExecuteNonQuery(dbCommand) > 0) { item = GetCategoryTemplateById(categoryTemplateId); } return(item); }
/// <summary> /// Inserts a category template /// </summary> /// <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 override DBCategoryTemplate InsertCategoryTemplate(string Name, string TemplatePath, int DisplayOrder, DateTime CreatedOn, DateTime UpdatedOn) { DBCategoryTemplate categoryTemplate = null; Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_CategoryTemplateInsert"); db.AddOutParameter(dbCommand, "CategoryTemplateID", DbType.Int32, 0); db.AddInParameter(dbCommand, "Name", DbType.String, Name); db.AddInParameter(dbCommand, "TemplatePath", DbType.String, TemplatePath); db.AddInParameter(dbCommand, "DisplayOrder", DbType.Int32, DisplayOrder); db.AddInParameter(dbCommand, "CreatedOn", DbType.DateTime, CreatedOn); db.AddInParameter(dbCommand, "UpdatedOn", DbType.DateTime, UpdatedOn); if (db.ExecuteNonQuery(dbCommand) > 0) { int CategoryTemplateID = Convert.ToInt32(db.GetParameterValue(dbCommand, "@CategoryTemplateID")); categoryTemplate = GetCategoryTemplateByID(CategoryTemplateID); } return(categoryTemplate); }
/// <summary> /// Gets a category template /// </summary> /// <param name="categoryTemplateId">Category template identifier</param> /// <returns>A category template</returns> public override DBCategoryTemplate GetCategoryTemplateById(int categoryTemplateId) { DBCategoryTemplate item = null; if (categoryTemplateId == 0) { return(item); } Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_CategoryTemplateLoadByPrimaryKey"); db.AddInParameter(dbCommand, "CategoryTemplateID", DbType.Int32, categoryTemplateId); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { item = GetCategoryTemplateFromReader(dataReader); } } return(item); }