public async Task <IActionResult> BrandLayoutAdd(BrandLayoutModel model) { if (!ModelState.IsValid) { return(Json(new DataSourceResult { Errors = ModelState.SerializeErrors() })); } if (ModelState.IsValid) { var layout = new BrandLayout(); layout = model.ToEntity(layout); await _brandLayoutService.InsertBrandLayout(layout); return(new JsonResult("")); } return(ErrorForKendoGridJson(ModelState)); }
public async Task <IActionResult> BrandLayoutUpdate(BrandLayoutModel model) { if (!ModelState.IsValid) { return(Json(new DataSourceResult { Errors = ModelState.SerializeErrors() })); } var layout = await _brandLayoutService.GetBrandLayoutById(model.Id); if (layout == null) { throw new ArgumentException("No layout found with the specified id"); } if (ModelState.IsValid) { layout = model.ToEntity(layout); await _brandLayoutService.UpdateBrandLayout(layout); return(new JsonResult("")); } return(ErrorForKendoGridJson(ModelState)); }
public static BrandLayout ToEntity(this BrandLayoutModel model, BrandLayout destination) { return(model.MapTo(destination)); }
public static BrandLayout ToEntity(this BrandLayoutModel model) { return(model.MapTo <BrandLayoutModel, BrandLayout>()); }