public static CommodityType BindCommodityType(CommodityTypeViewModel commodityTypeViewModel, CommodityType commodityType = null)
 {
     var target = commodityType ?? new CommodityType();
     target.CommodityTypeID = commodityTypeViewModel.CommodityTypeId;
     target.Name = commodityTypeViewModel.Name;
     return target;
 }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }