public void ShouldUpdateCommodityType()
 {
     var commdityType = new CommodityTypeViewModel() { CommodityTypeId = 1, Name = "CSB" };
     var request = new DataSourceRequest();
     var result = _commodityTypeController.CommodityType_Update(request,commdityType);
     Assert.IsInstanceOf<JsonResult>(result);
 }
 public static CommodityType BindCommodityType(CommodityTypeViewModel commodityTypeViewModel, CommodityType commodityType = null)
 {
     var target = commodityType ?? new CommodityType();
     target.CommodityTypeID = commodityTypeViewModel.CommodityTypeId;
     target.Name = commodityTypeViewModel.Name;
     return target;
 }
 public ActionResult CommodityType_Create([DataSourceRequest] DataSourceRequest request, CommodityTypeViewModel commodityTypeViewModel)
 {
     if (commodityTypeViewModel != null && ModelState.IsValid)
     {
         var commodityType = CommodityTypeViewModelBinder.BindCommodityType(commodityTypeViewModel);
         _commodityTypeService.AddCommodityType(commodityType);
     }
     return Json(new[] {commodityTypeViewModel}.ToDataSourceResult(request, ModelState));
 }
        public ActionResult CommodityType_Update([DataSourceRequest] DataSourceRequest request, CommodityTypeViewModel commodityTypeViewModel)
        {
            if (commodityTypeViewModel != null && ModelState.IsValid)
            {
                var target = _commodityTypeService.FindById(commodityTypeViewModel.CommodityTypeId);
                var commodityType = CommodityTypeViewModelBinder.BindCommodityType(commodityTypeViewModel,target);

                _commodityTypeService.EditCommodityType(commodityType);
            }

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