public async Task <IActionResult> ProductLayoutAdd(ProductLayoutModel model) { if (!ModelState.IsValid) { return(Json(new DataSourceResult { Errors = ModelState.SerializeErrors() })); } if (ModelState.IsValid) { var layout = new ProductLayout(); layout = model.ToEntity(layout); await _productLayoutService.InsertProductLayout(layout); return(new JsonResult("")); } return(ErrorForKendoGridJson(ModelState)); }
public async Task <IActionResult> ProductLayoutUpdate(ProductLayoutModel model) { if (!ModelState.IsValid) { return(Json(new DataSourceResult { Errors = ModelState.SerializeErrors() })); } var layout = await _productLayoutService.GetProductLayoutById(model.Id); if (layout == null) { throw new ArgumentException("No template found with the specified id"); } if (ModelState.IsValid) { layout = model.ToEntity(layout); await _productLayoutService.UpdateProductLayout(layout); return(new JsonResult("")); } return(ErrorForKendoGridJson(ModelState)); }
public static ProductLayout ToEntity(this ProductLayoutModel model, ProductLayout destination) { return(model.MapTo(destination)); }
public static ProductLayout ToEntity(this ProductLayoutModel model) { return(model.MapTo <ProductLayoutModel, ProductLayout>()); }