Esempio n. 1
0
        public async Task <IActionResult> CollectionLayoutAdd(CollectionLayoutModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new DataSourceResult {
                    Errors = ModelState.SerializeErrors()
                }));
            }
            if (ModelState.IsValid)
            {
                var layout = new CollectionLayout();
                layout = model.ToEntity(layout);
                await _collectionLayoutService.InsertCollectionLayout(layout);

                return(new JsonResult(""));
            }
            return(ErrorForKendoGridJson(ModelState));
        }
Esempio n. 2
0
        public async Task <IActionResult> CollectionLayoutUpdate(CollectionLayoutModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new DataSourceResult {
                    Errors = ModelState.SerializeErrors()
                }));
            }

            var layout = await _collectionLayoutService.GetCollectionLayoutById(model.Id);

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

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