public ActionResult CommoditySource_Create([DataSourceRequest] DataSourceRequest request, CommoditySourceViewModel commoditySourceViewModel) { if (commoditySourceViewModel != null && ModelState.IsValid) { var commoditySource = CommoditySourceViewModelBinder.BindCommoditySource(commoditySourceViewModel); _commoditySourceService.AddCommoditySource(commoditySource); } return Json(new[] { commoditySourceViewModel }.ToDataSourceResult(request, ModelState)); }
public static CommoditySource BindCommoditySource(CommoditySourceViewModel commoditySourceViewModel, CommoditySource commoditySource = null) { var target = commoditySource ?? new CommoditySource(); target.CommoditySourceID = commoditySourceViewModel.CommoditySourceID; target.Name = commoditySourceViewModel.Name; return target; }
public ActionResult CommoditySource_Update([DataSourceRequest] DataSourceRequest request, CommoditySourceViewModel commoditySourceViewModel) { if (commoditySourceViewModel != null && ModelState.IsValid) { var target = _commoditySourceService.FindById(commoditySourceViewModel.CommoditySourceID); var commoditySource = CommoditySourceViewModelBinder.BindCommoditySource(commoditySourceViewModel, target); _commoditySourceService.EditCommoditySource(commoditySource); } return Json(new[] { commoditySourceViewModel }.ToDataSourceResult(request, ModelState)); }