Esempio n. 1
0
 public void CanCreateProgram()
 {
     var request = new DataSourceRequest();
        var programViewModel = new ProgramViewModel {ProgramID = 1, ProgramName = "PSNP", Description = "PSNP Program"};
        var result = _programController.Program_Create(request, programViewModel);
        //Assert
        Assert.IsInstanceOf<JsonResult>(result);
 }
Esempio n. 2
0
 public ActionResult Program_Destroy([DataSourceRequest] DataSourceRequest request, ProgramViewModel model)
 {
     if (model != null && ModelState.IsValid)
     {
         var program = _programService.FindById(model.ProgramID);
         _programService.DeleteProgram(program);
     }
     return Json(ModelState.ToDataSourceResult());
 }
Esempio n. 3
0
        public ActionResult Program_Create([DataSourceRequest] DataSourceRequest request, ProgramViewModel program)
        {
            if (program != null && ModelState.IsValid)
            {

                _programService.AddProgram(BindProgram(program));
            }

            return Json(new[] { program }.ToDataSourceResult(request, ModelState));
        }
Esempio n. 4
0
        public ActionResult Program_Update([DataSourceRequest] DataSourceRequest request, ProgramViewModel model)
        {
            if (model != null && ModelState.IsValid)
            {
                var origin = _programService.FindById(model.ProgramID);
                origin.Name = model.ProgramName;
                origin.Description = model.Description;
                origin.LongName = model.LongName;

                _programService.EditProgram(origin);
            }
            return Json(new[] { model }.ToDataSourceResult(request, ModelState));
        }
Esempio n. 5
0
 private Program BindProgram(ProgramViewModel model)
 {
     if (model == null) return null;
     var program = new Program()
     {
         ProgramID = model.ProgramID,
         Name = model.ProgramName,
         Description = model.Description,
         LongName = model.LongName,
         ShortCode = model.ShortCode
     };
     return program;
 }