Esempio n. 1
0
 public Category(string fileName, string fileExt, string title, string slug,
                 string description, string filePath,
                 string content        = "",
                 CategoryLayout layout = CategoryLayout.List)
 {
     this.fileName    = fileName; this.fileExt = fileExt;
     this.layout      = layout;
     this.title       = title;
     this.slug        = slug;
     this.description = description;
     this.filePath    = filePath;
     this.content     = content;
 }
        /// <summary>
        /// Insert new category layout
        /// </summary>
        /// <param name="categoryLayout">Category layout</param>
        public virtual async Task InsertCategoryLayout(CategoryLayout categoryLayout)
        {
            if (categoryLayout == null)
            {
                throw new ArgumentNullException(nameof(categoryLayout));
            }

            await _categoryLayoutRepository.InsertAsync(categoryLayout);

            //clear cache
            await _cacheBase.RemoveByPrefix(CacheKey.CATEGORY_LAYOUT_PATTERN_KEY);

            //event notification
            await _mediator.EntityInserted(categoryLayout);
        }
Esempio n. 3
0
        public async Task <IActionResult> CategoryLayoutAdd(CategoryLayoutModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new DataSourceResult {
                    Errors = ModelState.SerializeErrors()
                }));
            }
            if (ModelState.IsValid)
            {
                var layout = new CategoryLayout();
                layout = model.ToEntity(layout);
                await _categoryLayoutService.InsertCategoryLayout(layout);

                return(new JsonResult(""));
            }
            return(ErrorForKendoGridJson(ModelState));
        }
 public static CategoryLayoutModel ToModel(this CategoryLayout entity)
 {
     return(entity.MapTo <CategoryLayout, CategoryLayoutModel>());
 }
 public static CategoryLayout ToEntity(this CategoryLayoutModel model, CategoryLayout destination)
 {
     return(model.MapTo(destination));
 }