public ProductTypeTemplatePath(ICommerceDataDir commerceDataDir, ProductType productType) { var basePhysicalPath = Path.Combine(commerceDataDir.DataPhysicalPath, DirName, productType.Name); var baseVirtualPath = UrlUtility.Combine(commerceDataDir.DataVirutalPath, DirName, productType.Name); BaseDirPath = new HttpFilePath() { PhysicalPath = basePhysicalPath, VirtualPath = baseVirtualPath }; CustomFieldsTemplatePath = new HttpFilePath() { PhysicalPath = Path.Combine(basePhysicalPath, "CustomFields.cshtml"), VirtualPath = UrlUtility.Combine(baseVirtualPath, "CustomFields.cshtml") }; VariantGridTemplatePath = new HttpFilePath() { PhysicalPath = Path.Combine(basePhysicalPath, "VariantGrid.cshtml"), VirtualPath = UrlUtility.Combine(baseVirtualPath, "VariantGrid.cshtml") }; VariantCreateTemplatePath = new HttpFilePath() { PhysicalPath = Path.Combine(basePhysicalPath, "VariantCreate.cshtml"), VirtualPath = UrlUtility.Combine(baseVirtualPath, "VariantCreate.cshtml") }; VariantEditTemplatePath = new HttpFilePath() { PhysicalPath = Path.Combine(basePhysicalPath, "VariantEdit.cshtml"), VirtualPath = UrlUtility.Combine(baseVirtualPath, "VariantEdit.cshtml") }; }
/// <summary> /// Adds the specified item. /// </summary> /// <param name="item">The item.</param> public void Add(ProductType item) { var path = GetSettingFilePath(item.Name); IOUtility.EnsureDirectoryExists(Path.GetDirectoryName(path)); locker.EnterWriteLock(); try { Kooboo.Runtime.Serialization.DataContractSerializationHelper.Serialize(item, path); } finally { locker.ExitWriteLock(); } }
public void Test_Add_Get_Update_Remove_ProductTypeProvider() { var productType1 = new ProductType { UUID = "1", Name = "PT1" }; var productType2 = new ProductType { UUID = "2", Name = "PT2" }; foreach (ProductType item in provider.All()) { provider.Remove(item); } //Add provider.Add(productType1); provider.Add(productType2); Console.WriteLine("AddOK!"); //All IEnumerable<ProductType> productTypes = provider.All(); Assert.AreEqual(2, productTypes.Count()); //Get var productTypeActual1 = provider.Get(productType1); Assert.IsNotNull(productTypeActual1); Console.WriteLine("GetOK!"); //Update var productType3 = new ProductType { UUID = "2", Name = "PT3" }; provider.Update(@productType3, productType2); var productTypeActual2 = provider.Get(productType2); Assert.IsNull(productTypeActual2); var productTypeActual3 = provider.Get(productType3); Assert.IsNotNull(productTypeActual3); Console.WriteLine("Update OK!"); //Remove provider.Remove(productType1); var productTypeActual4 = provider.Get(productType1); Assert.IsNull(productTypeActual4); Console.WriteLine("Remove OK!"); }
public void TestInitialize() { productType = new ProductType() { Name = "Notebook", CustomFields = new List<ProductFieldType>() { new ProductFieldType(){ Name="Color", ControlType ="TextBox", DataType = Common.DataType.String }, new ProductFieldType(){ Name="Size", ControlType ="TextBox", DataType = Common.DataType.String }, new ProductFieldType(){ Name="Style", ControlType = "RadioList", DataType = Common.DataType.String, SelectionItems= new Kooboo.CMS.Form.SelectListItem[]{ new Kooboo.CMS.Form.SelectListItem(){ Text ="极致轻薄",Value="极致轻薄"}, new Kooboo.CMS.Form.SelectListItem(){ Text ="多彩时尚",Value="多彩时尚"}, new Kooboo.CMS.Form.SelectListItem(){ Text ="游戏狂人",Value="游戏狂人"}, new Kooboo.CMS.Form.SelectListItem(){ Text ="全能商务",Value="全能商务"} } } }, Variants = new List<ProductFieldType>() { new ProductFieldType(){ Name="Memory", ControlType = "RadioList", DataType = Common.DataType.String, SelectionItems= new Kooboo.CMS.Form.SelectListItem[]{ new Kooboo.CMS.Form.SelectListItem(){ Text ="4G",Value="4G"}, new Kooboo.CMS.Form.SelectListItem(){ Text ="8G",Value="8G"} } } } }; }
public virtual string GenerateVariantGridForm(ProductType productType) { throw new NotImplementedException(); }
public virtual string GenerateCustomeFieldsEditForm(ProductType productType) { throw new NotImplementedException(); }
/// <summary> /// Updates the specified new. /// </summary> /// <param name="new">The new.</param> /// <param name="old">The old.</param> public void Update(ProductType @new, ProductType old) { Remove(old); Add(@new); }
/// <summary> /// Removes the specified item. /// </summary> /// <param name="item">The item.</param> public void Remove(ProductType item) { locker.EnterWriteLock(); try { var itemPath = GetItemPath(item.Name); Kooboo.IO.IOUtility.DeleteDirectory(itemPath, true); } finally { locker.ExitWriteLock(); } }
/// <summary> /// Gets the specified dummy. /// </summary> /// <param name="dummy">The dummy.</param> /// <returns></returns> public ProductType Get(ProductType dummy) { var filepath = GetSettingFilePath(dummy.Name); if (File.Exists(filepath)) { locker.EnterReadLock(); try { var item = (ProductType)DataContractSerializationHelper.Deserialize(dummy.GetType(), KnownTypes, filepath); return item; } finally { locker.ExitReadLock(); } } return default(ProductType); }