Esempio n. 1
0
 public ActionResult Commodity_Create([DataSourceRequest] DataSourceRequest request, CommodityViewModel commodityViewModel)
 {
     if (commodityViewModel != null && ModelState.IsValid)
     {
         var commodity = CommodityViewModelBinder.BindCommodity(commodityViewModel);
         _commodityService.AddCommodity(commodity);
     }
     return(Json(new[] { commodityViewModel }.ToDataSourceResult(request, ModelState)));
 }
Esempio n. 2
0
        public ActionResult Create(Commodity commodity)
        {
            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.AddCommodity(commodity);
                return(Json(new { success = true }));
            }

            Create(commodity.ParentID != null ? 0 : 1, commodity.ParentID);
            return(PartialView(commodity));
        }