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