public ActionResult CommodityGrade_Create([DataSourceRequest] DataSourceRequest request, CommodityGradeViewModel commodityGradeViewModel) { if (commodityGradeViewModel != null && ModelState.IsValid) { var commodityGrade = CommodityGradeViewModelBinder.BindCommodityGrade(commodityGradeViewModel); _commodityGradeService.AddCommodityGrade(commodityGrade); } return Json(new[] {commodityGradeViewModel}.ToDataSourceResult(request, ModelState)); }
public static CommodityGrade BindCommodityGrade(CommodityGradeViewModel commodityGradeViewModel, CommodityGrade commodityGrade = null) { return commodityGrade ?? new CommodityGrade() { CommodityGradeID=commodityGradeViewModel.CommodityGradeID, Name=commodityGradeViewModel.Name, Description=commodityGradeViewModel.Description }; }
public ActionResult CommodityGrade_Update([DataSourceRequest] DataSourceRequest request, CommodityGradeViewModel commodityGradeViewModel) { if (commodityGradeViewModel != null && ModelState.IsValid) { var target = _commodityGradeService.FindById(commodityGradeViewModel.CommodityGradeID); var commodityGrade = CommodityGradeViewModelBinder.BindCommodityGrade(commodityGradeViewModel, target); _commodityGradeService.EditCommodityGrade(commodityGrade); } return Json(new[] {commodityGradeViewModel}.ToDataSourceResult(request, ModelState)); }