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 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 CommodityTypes() : base() { InitializeComponent(); this.toolstripChild = this.toolStripChildForm; this.fastListIndex = this.fastCommodityTypeIndex; this.commodityTypeAPIs = new CommodityTypeAPIs(CommonNinject.Kernel.Get <ICommodityTypeAPIRepository>()); this.commodityTypeViewModel = CommonNinject.Kernel.Get <CommodityTypeViewModel>(); this.commodityTypeViewModel.PropertyChanged += new PropertyChangedEventHandler(ModelDTO_PropertyChanged); this.baseDTO = this.commodityTypeViewModel; }
public ActionResult DeleteJson([DataSourceRequest] DataSourceRequest request, CommodityTypeViewModel viewModel) { var original = _commodityTypeService.FindById(viewModel.CommodityTypeId); _commodityTypeService.DeleteCommodityType(original); return(Json(new[] { viewModel }.ToDataSourceResult(request, ModelState))); }
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))); }
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))); }
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))); }
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))); }