Esempio n. 1
0
 public void SetCustomField(string name, string value)
 {
     var field = CustomFields.FirstOrDefault(f => f.Name == name);
     if (field == null)
     {
         field = new CategoryCustomField(name, value);
         CustomFields.Add(field);
     }
     else
     {
         field.Value = value;
     }
 }
Esempio n. 2
0
        public void SetCustomField(string name, string value)
        {
            var field = CustomFields.FirstOrDefault(f => f.Name == name);

            if (field == null)
            {
                field = new CategoryCustomField(name, value);
                CustomFields.Add(field);
            }
            else
            {
                field.Value = value;
            }
        }
Esempio n. 3
0
        public void UpdateTo(Category category)
        {
            category.Id = this.Id;
            category.Name = (this.Name ?? string.Empty).Trim();
            category.Photo = (this.Photo ?? string.Empty).Trim();
            category.Description = (this.Description ?? string.Empty).Trim();
            category.Published = this.Published;
            //
            //if (!string.IsNullOrEmpty(this.ParentId)) {
            //    category.Parent = new Category() { Id = int.Parse(this.ParentId) };
            //}
            //
            if (this.Children != null)
            {
                category.Children = new List<Category>();
                foreach (var item in this.Children)
                {
                    var obj = new Category();
                    item.UpdateTo(obj);
                    category.Children.Add(obj);
                }
            }
            if (this.CustomFields != null && this.CustomFields.Count > 0)
            {
                category.CustomFields = new List<CategoryCustomField>();
                foreach (var cfm in this.CustomFields)
                {
                    var cf = new CategoryCustomField();
                    cf.CategoryId = this.Id;
                    cf.Name = cfm.Name;
                    cf.Value = cfm.Value;

                    category.CustomFields.Add(cf);
                }
            }
        }