/// <summary> /// Updates the manufacturer template /// </summary> /// <param name="manufacturerTemplate">Manufacturer template</param> public void UpdateManufacturerTemplate(ManufacturerTemplate manufacturerTemplate) { if (manufacturerTemplate == null) { throw new ArgumentNullException("manufacturerTemplate"); } manufacturerTemplate.Name = CommonHelper.EnsureNotNull(manufacturerTemplate.Name); manufacturerTemplate.Name = CommonHelper.EnsureMaximumLength(manufacturerTemplate.Name, 100); manufacturerTemplate.TemplatePath = CommonHelper.EnsureNotNull(manufacturerTemplate.TemplatePath); manufacturerTemplate.TemplatePath = CommonHelper.EnsureMaximumLength(manufacturerTemplate.TemplatePath, 200); if (!_context.IsAttached(manufacturerTemplate)) { _context.ManufacturerTemplates.Attach(manufacturerTemplate); } _context.SaveChanges(); if (this.CacheEnabled) { _cacheManager.RemoveByPattern(MANUFACTURERTEMPLATES_PATTERN_KEY); } }
public ManufacturerTemplate SaveInfo() { ManufacturerTemplate manufacturerTemplate = this.TemplateService.GetManufacturerTemplateById(this.ManufacturerTemplateId); if (manufacturerTemplate != null) { manufacturerTemplate.Name = txtName.Text; manufacturerTemplate.TemplatePath = txtTemplatePath.Text; manufacturerTemplate.DisplayOrder = txtDisplayOrder.Value; manufacturerTemplate.UpdatedOn = DateTime.UtcNow; this.TemplateService.UpdateManufacturerTemplate(manufacturerTemplate); } else { DateTime now = DateTime.UtcNow; manufacturerTemplate = new ManufacturerTemplate() { Name = txtName.Text, TemplatePath = txtTemplatePath.Text, DisplayOrder = txtDisplayOrder.Value, CreatedOn = now, UpdatedOn = now }; this.TemplateService.InsertManufacturerTemplate(manufacturerTemplate); } return manufacturerTemplate; }
/// <summary> /// Gets a manufacturer template /// </summary> /// <param name="ManufacturerTemplateID">Manufacturer template identifier</param> /// <returns>Manufacturer template</returns> public static ManufacturerTemplate GetManufacturerTemplateByID(int ManufacturerTemplateID) { if (ManufacturerTemplateID == 0) { return(null); } string key = string.Format(MANUFACTURERTEMPLATES_BY_ID_KEY, ManufacturerTemplateID); object obj2 = NopCache.Get(key); if (TemplateManager.CacheEnabled && (obj2 != null)) { return((ManufacturerTemplate)obj2); } DBManufacturerTemplate dbItem = DBProviderManager <DBTemplateProvider> .Provider.GetManufacturerTemplateByID(ManufacturerTemplateID); ManufacturerTemplate manufacturerTemplate = DBMapping(dbItem); if (TemplateManager.CacheEnabled) { NopCache.Max(key, manufacturerTemplate); } return(manufacturerTemplate); }
private static ManufacturerTemplateCollection DBMapping(DBManufacturerTemplateCollection dbCollection) { if (dbCollection == null) { return(null); } ManufacturerTemplateCollection collection = new ManufacturerTemplateCollection(); foreach (DBManufacturerTemplate dbItem in dbCollection) { ManufacturerTemplate item = DBMapping(dbItem); collection.Add(item); } return(collection); }
/// <summary> /// Updates the manufacturer template /// </summary> /// <param name="ManufacturerTemplateID">Manufacturer template identifer</param> /// <param name="Name">The manufacturer template identifier</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>Manufacturer template</returns> public static ManufacturerTemplate UpdateManufacturerTemplate(int ManufacturerTemplateID, string Name, string TemplatePath, int DisplayOrder, DateTime CreatedOn, DateTime UpdatedOn) { CreatedOn = DateTimeHelper.ConvertToUtcTime(CreatedOn); UpdatedOn = DateTimeHelper.ConvertToUtcTime(UpdatedOn); DBManufacturerTemplate dbItem = DBProviderManager <DBTemplateProvider> .Provider.UpdateManufacturerTemplate(ManufacturerTemplateID, Name, TemplatePath, DisplayOrder, CreatedOn, UpdatedOn); ManufacturerTemplate manufacturerTemplate = DBMapping(dbItem); if (TemplateManager.CacheEnabled) { NopCache.RemoveByPattern(MANUFACTURERTEMPLATES_PATTERN_KEY); } return(manufacturerTemplate); }
private static ManufacturerTemplate DBMapping(DBManufacturerTemplate dbItem) { if (dbItem == null) { return(null); } var item = new ManufacturerTemplate(); item.ManufacturerTemplateId = dbItem.ManufacturerTemplateId; 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 manufacturer template /// </summary> /// <param name="manufacturerTemplate">Manufacturer template</param> public void UpdateManufacturerTemplate(ManufacturerTemplate manufacturerTemplate) { if (manufacturerTemplate == null) throw new ArgumentNullException("manufacturerTemplate"); manufacturerTemplate.Name = CommonHelper.EnsureNotNull(manufacturerTemplate.Name); manufacturerTemplate.Name = CommonHelper.EnsureMaximumLength(manufacturerTemplate.Name, 100); manufacturerTemplate.TemplatePath = CommonHelper.EnsureNotNull(manufacturerTemplate.TemplatePath); manufacturerTemplate.TemplatePath = CommonHelper.EnsureMaximumLength(manufacturerTemplate.TemplatePath, 200); if (!_context.IsAttached(manufacturerTemplate)) _context.ManufacturerTemplates.Attach(manufacturerTemplate); _context.SaveChanges(); if (this.CacheEnabled) { _cacheManager.RemoveByPattern(MANUFACTURERTEMPLATES_PATTERN_KEY); } }