public ActionResult Donor_Create([DataSourceRequest] DataSourceRequest request, DonorModel donor) { if (donor != null && ModelState.IsValid) { _donorService.AddDonor(BindDonor(donor)); } return Json(new[] { donor }.ToDataSourceResult(request, ModelState)); }
public ActionResult Donor_Update([DataSourceRequest] DataSourceRequest request, DonorModel model) { if (model != null && ModelState.IsValid) { var origin = _donorService.FindById(model.DonorID); origin.DonorCode = model.DonorCode; origin.Name = model.Name; origin.IsResponsibleDonor = model.IsResponsibleDonor; origin.IsSourceDonor = model.IsSourceDonor; origin.LongName = model.LongName; _donorService.EditDonor(origin); } return Json(new[] { model }.ToDataSourceResult(request, ModelState)); }
public void CanCreateDonor() { var donor = new DonorModel { DonorID = 2, DonorCode = "UN", Name = "United Nations", IsResponsibleDonor = false, IsSourceDonor = true, LongName = "United Nations" }; var request = new DataSourceRequest(); var result = _donorController.Donor_Create(request, donor); Assert.IsInstanceOf<JsonResult>(result); }
private Donor BindDonor(DonorModel model) { if (model == null) return null; var donor = new Donor() { DonorID = model.DonorID, DonorCode = model.DonorCode, Name = model.Name, IsResponsibleDonor = model.IsResponsibleDonor, IsSourceDonor = model.IsResponsibleDonor, LongName = model.LongName }; return donor; }