Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        public void DeletetTest()
        {
            using (var trans = TransHelper.NewScope())
            {
                //  arrange
                var expected = BiayaDataFactory();
                _biayaDal.Insert(expected);

                //  act
                _biayaDal.Delete("A1");

                //  assert
            }
        }