示例#1
0
        public ActionResult Commodity_Update([DataSourceRequest] DataSourceRequest request, CommodityViewModel commodityViewModel)
        {
            if (commodityViewModel != null && ModelState.IsValid)
            {
                var target    = _commodityService.FindById(commodityViewModel.CommodityID);
                var commodity = CommodityViewModelBinder.BindCommodity(commodityViewModel, target);
                _commodityService.EditCommodity(commodity);
            }

            return(Json(new[] { commodityViewModel }.ToDataSourceResult(request, ModelState)));
        }
 public bool EditCommodity([FromServices]ICommodityService CommodityService, EditCommodityDto commodity)
 {
     //判断标签个数是否大于5个
     if (commodity.Tag.Length > 5)
     {
         return false;
     }
     else
     {
         return CommodityService.EditCommodity(commodity);
     }
 }
示例#3
0
        public ActionResult Edit(Commodity commodity)
        {
            // TODO: move this to a shared helper function.
            if (!_commodityService.IsCodeValid(commodity.CommodityID, commodity.CommodityCode))
            {
                ModelState.AddModelError("CommodityCode", @"Commodity Code should be unique.");
            }
            if (!_commodityService.IsNameValid(commodity.CommodityID, commodity.Name))
            {
                ModelState.AddModelError("Name", @"Commodity Name should be unique.");
            }

            if (ModelState.IsValid)
            {
                _commodityService.EditCommodity(commodity);
                return(Json(new { success = true }));
            }
            Edit(commodity.CommodityID);
            return(PartialView(commodity));
        }