Esempio n. 1
0
        public void CanCreateUnit()
        {
            var request = new DataSourceRequest();
               var unitViewModel = new UnitViewModel{UnitID = 1,UnitName = "Killo Gram"};
               var result = _unitController.Unit_Create(request, unitViewModel);

               Assert.IsInstanceOf<JsonResult>(result);
        }
Esempio n. 2
0
 public ActionResult Unit_Destroy([DataSourceRequest] DataSourceRequest request, UnitViewModel model)
 {
     if (model != null && ModelState.IsValid)
     {
         var unit = _unitService.FindById(model.UnitID);
         _unitService.DeleteUnit(unit);
     }
     return Json(ModelState.ToDataSourceResult());
 }
Esempio n. 3
0
 public ActionResult Unit_Update([DataSourceRequest] DataSourceRequest request, UnitViewModel model)
 {
     if (model != null && ModelState.IsValid)
     {
         var origin = _unitService.FindById(model.UnitID);
         origin.Name = model.UnitName;
         _unitService.EditUnit(origin);
     }
     return Json(new[] { model }.ToDataSourceResult(request, ModelState));
 }
Esempio n. 4
0
        public ActionResult Unit_Create([DataSourceRequest] DataSourceRequest request, UnitViewModel unit)
        {
            if (unit != null && ModelState.IsValid)
            {

                _unitService.AddUnit(BindUnit(unit));
            }

            return Json(new[] { unit }.ToDataSourceResult(request, ModelState));
        }
Esempio n. 5
0
 private Unit BindUnit(UnitViewModel model)
 {
     if (model == null) return null;
     var unit = new Unit()
         {
             UnitID = model.UnitID,
             Name = model.UnitName
         };
     return unit;
 }