public BiayaModel Save(BiayaModel model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } if (model.NilaiBiaya <= 0) { throw new ArgumentException("Nilai Biaya invalid"); } var jenisBiaya = _jenisBiayaBL.GetData(model.JenisBiayaID); if (jenisBiaya == null) { throw new ArgumentException("JenisBiayaID invalid"); } var jenisKas = _jenisKasBL.GetData(model.JenisKasID); if (jenisKas == null) { throw new ArgumentException("JenisKasID invalid"); } if (model.BiayaID.Trim() == "") { model.BiayaID = GenNewID(); } using (var trans = TransHelper.NewScope()) { // hapus data lama _biayaDal.Delete(model.BiayaID); // simpan data baru _biayaDal.Insert(model); trans.Complete(); } return(model); }
public void InsertTest() { using (var trans = TransHelper.NewScope()) { // arrange var expected = BiayaDataFactory(); // act _biayaDal.Insert(expected); // assert } }