Example #1
0
        public SupplierModel Save(SupplierModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            //  validasi nama
            if (model.SupplierName.Trim() == "")
            {
                throw new ArgumentException("SupplierName kosong");
            }

            //  simpan
            using (var trans = TransHelper.NewScope())
            {
                if (model.SupplierID.Trim() == "")
                {
                    model.SupplierID = GenNewID();
                }

                _supplierDal.Delete(model.SupplierID);
                _supplierDal.Insert(model);

                //  update pihak kedua
                _pihakKeduaDal.Delete(model.SupplierID);
                var pihakKedua = new PihakKeduaModel
                {
                    PihakKeduaID   = model.SupplierID,
                    PihakKeduaName = model.SupplierName
                };
                _pihakKeduaDal.Insert(pihakKedua);

                trans.Complete();
            }
            return(model);
        }
Example #2
0
        public PegawaiModel Save(PegawaiModel pegawai)
        {
            if (pegawai == null)
            {
                throw new ArgumentNullException(nameof(pegawai));
            }

            if (pegawai.PegawaiName.Trim() == "")
            {
                throw new ArgumentException("Pegawai Name kosong");
            }

            using (var trans = TransHelper.NewScope())
            {
                if (pegawai.PegawaiID.Trim() == "")
                {
                    pegawai.PegawaiID = GenNewID();
                }

                //  simapn (hapus >> simpan)
                _pegawaiDal.Delete(pegawai.PegawaiID);
                _pegawaiDal.Insert(pegawai);

                //  update pihak kedua
                _pihakKeduaDal.Delete(pegawai.PegawaiID);
                var pihakKedua = new PihakKeduaModel
                {
                    PihakKeduaID   = pegawai.PegawaiID,
                    PihakKeduaName = pegawai.PegawaiName
                };
                _pihakKeduaDal.Insert(pihakKedua);

                trans.Complete();
            }

            return(pegawai);
        }
Example #3
0
 public void Delete(string id)
 {
     _pihakKeduaDal.Delete(id);
 }