public static CommodityType BindCommodityType(CommodityTypeViewModel commodityTypeViewModel, CommodityType commodityType = null)
 {
     var target = commodityType ?? new CommodityType();
     target.CommodityTypeID = commodityTypeViewModel.CommodityTypeId;
     target.Name = commodityTypeViewModel.Name;
     return target;
 }
Пример #2
0
        public ActionResult CreateJson([DataSourceRequest] DataSourceRequest request, CommodityTypeViewModel viewModel)
        {
            if (viewModel != null && ModelState.IsValid)
            {
                CommodityType original = new CommodityType
                {
                    Name = viewModel.Name,

                };
                _commodityTypeService.AddCommodityType(original);
            }
            return Json(new[] { viewModel }.ToDataSourceResult(request, ModelState));
        }
Пример #3
0
        public ActionResult UpdateJson([DataSourceRequest] DataSourceRequest request, CommodityTypeViewModel viewModel)
        {
            if (viewModel != null && ModelState.IsValid)
            {
                var original = _commodityTypeService.FindById(viewModel.CommodityTypeId);
                original.Name = viewModel.Name;

                _commodityTypeService.EditCommodityType(original);
            }
            return Json(new[] { viewModel }.ToDataSourceResult(request, ModelState));
        }
Пример #4
0
        public ActionResult DeleteJson([DataSourceRequest] DataSourceRequest request, CommodityTypeViewModel viewModel)
        {
            var original = _commodityTypeService.FindById(viewModel.CommodityTypeId);
            _commodityTypeService.DeleteCommodityType(original);

            return Json(new[] { viewModel }.ToDataSourceResult(request, ModelState));
        }