public void InsertTest() { using (var trans = TransHelper.NewScope()) { // arrange var expected = StokAdjustment2DataFactory(); // act _stokAdjustment2Dal.Insert(expected); // assert } }
public StokAdjustmentModel Save(StokAdjustmentModel stokAdjustment) { // validasi var result = stokAdjustment; result = TryValidate(stokAdjustment); var trsID = ""; // save using (var trans = TransHelper.NewScope()) { // edit: delete data lama if (stokAdjustment.StokAdjustmentID.Trim() != "") { // kembalikan stok lama _stokAdjustment2Dal.Delete(stokAdjustment.StokAdjustmentID); _stokAdjustmentDal.Delete(stokAdjustment.StokAdjustmentID); trsID = stokAdjustment.StokAdjustmentID; } // baru: generate no.transaksi else { var prefix = "AJ" + DateTime.Now.ToString("yyMM"); trsID = _paramNoBL.GenNewID(prefix, 10); } // save header stokAdjustment.StokAdjustmentID = trsID; // delete data lama _stokAdjustment2Dal.Delete(trsID); _stokAdjustmentDal.Delete(trsID); // insert data baru _stokAdjustmentDal.Insert(stokAdjustment); foreach (var item in stokAdjustment.ListBrg) { item.StokAdjustmentID = trsID; item.StokAdjustmentID2 = string.Format("{0}-{1}", trsID, item.NoUrut.ToString().PadLeft(3, '0')); _stokAdjustment2Dal.Insert(item); } trans.Complete(); } return(result); }