示例#1
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));
        }
示例#2
0
        public async Task <IActionResult> CategoryLayoutUpdate(CategoryLayoutModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new DataSourceResult {
                    Errors = ModelState.SerializeErrors()
                }));
            }

            var layout = await _categoryLayoutService.GetCategoryLayoutById(model.Id);

            if (layout == null)
            {
                throw new ArgumentException("No layout found with the specified id");
            }
            if (ModelState.IsValid)
            {
                layout = model.ToEntity(layout);
                await _categoryLayoutService.UpdateCategoryLayout(layout);

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