コード例 #1
0
 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));
 }
コード例 #2
0
        public static CommodityGrade BindCommodityGrade(CommodityGradeViewModel commodityGradeViewModel, CommodityGrade commodityGrade = null)
        {
            return commodityGrade ?? new CommodityGrade()
            {
              CommodityGradeID=commodityGradeViewModel.CommodityGradeID,
              Name=commodityGradeViewModel.Name,
              Description=commodityGradeViewModel.Description

            };
        }
コード例 #3
0
        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));
        }