コード例 #1
0
        public CategoryViewModel ToViewModel()
        {
            var categoryViewModel = new CategoryViewModel();

            categoryViewModel.Id          = Id;
            categoryViewModel.Name        = Name;
            categoryViewModel.Description = Description;

            foreach (var categoryField in CategoryFields)
            {
                var categoryFieldViewModel = new CategoryFieldViewModel();
                categoryFieldViewModel.Id   = categoryField.Id;
                categoryFieldViewModel.Name = categoryField.Name;
                categoryFieldViewModel.Type = categoryField.Type;

                categoryViewModel.Fields.Add(categoryFieldViewModel);
            }

            categoryViewModel.Image = new ImageViewModel();

            if (ImageReference != null)
            {
                categoryViewModel.Image.Id  = ImageReference.Id;
                categoryViewModel.Image.Url = ImageReference.Url;
            }

            return(categoryViewModel);
        }
コード例 #2
0
 public CategoryField(CategoryFieldViewModel categoryFieldViewModel)
 {
     Id         = categoryFieldViewModel.Id;
     CategoryId = categoryFieldViewModel.CategoryId;
     Name       = categoryFieldViewModel.Name;
     Type       = categoryFieldViewModel.Type;
 }