public void LayananBL_GetById_Test() { // arrange // act var dummy = _layananBL.GetById("A"); // assert _layananDal.AssertWasCalled(x => x.GetById("A")); }
public void Save(DokterModel dokter) { // cek kode dokter if (dokter.Kode.Trim() == "") { throw new ArgumentException("KODE DOKTER kosong"); } // cek nama dokter if (dokter.Nama.Trim() == "") { throw new ArgumentException("NAMA DOKTER kosong"); } // composit: kode layanan if (dokter.KodeLayanan.Trim() != "") { LayananModel layanan = _layananBL.GetById(dokter.KodeLayanan); if (layanan == null) { throw new ArgumentException("KODE LAYANAN invalid"); } else if (_layananBL.GetById(layanan.Kode).Nama.Trim() == "") { throw new ArgumentException("KODE LAYANAN invalid"); } } //--save data if (!IsExist(dokter.Kode)) { _dokterDal.Insert(dokter); } else { _dokterDal.Update(dokter); } }
public void Save(JadwalHariModel jadwal) { //--validasi // dokter if (_dokterBL.GetById(jadwal.KodeDokter).Nama.Trim() == "") { throw new ArgumentException("Invalid DOKTER"); } // layanan if (_layananBL.GetById(jadwal.KodeLayanan).Nama.Trim() == "") { throw new ArgumentException("Invalid LAYANAN"); } // hari if (jadwal.Hari < 1 || jadwal.Hari > 7) { throw new ArgumentException("Invalid HARI"); } // jam mulai TimeSpan jamMulai; if (!TimeSpan.TryParse(jadwal.JamMulai, out jamMulai)) { throw new ArgumentException("Invalid JAM MULAI"); } // jam selesai TimeSpan jamSelesai; if (!TimeSpan.TryParse(jadwal.JamSelesai, out jamSelesai)) { throw new ArgumentException("Invalid JAM SELESAI"); } // urutan jam mulai-jam selesai if (TimeSpan.Compare(jamMulai, jamSelesai) == 1) { throw new ArgumentException("Invalid JAM MULAI-SELESAI"); } //--validasi detil per jam foreach (JadwalHariPerJamModel item in jadwal.JadwalPerJams) { // format jam TimeSpan jamDetil; if (!TimeSpan.TryParse(item.Jam, out jamDetil)) { throw new ArgumentException("Invalid Format Detil JAM"); } // jam detil harus berada di range jam di header if (TimeSpan.Compare(jamMulai, jamDetil) == 1) { throw new ArgumentException("Invalid Range Detil JAM"); } if (TimeSpan.Compare(jamDetil, jamSelesai) == 1) { throw new ArgumentException("Invalid Range Detil JAM"); } // booked tidak boleh melebihi max if (item.Booked > item.Max) { throw new ArgumentException("Invalid BOOKED QTY"); } } // cek duplikasi dokter-hari-jam (case beda jadwal sama (ini))) // ambil data header var result = from jadwalJam in jadwal.JadwalPerJams group jadwalJam by jadwalJam.Jam into jamGroup select new { Jam = jamGroup.Key, Count = jamGroup.Count() }; if (result.ToList().Exists(x => x.Count > 1)) { throw new ArgumentException("Duplicated JAM PRAKTEK"); } TransactionOptions tranOption = new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted }; using (TransactionScope tran = new TransactionScope(TransactionScopeOption.Required, tranOption)) { // generate kode jadwal jika kosong if (jadwal.Kode.Trim() == "") { ParamNoModel paramNo = _paramNoBL.GetById("JD"); jadwal.Kode = _paramNoBL.FormatKode(paramNo, 5, ""); _jadwalHariDal.Insert(jadwal); } else { _jadwalHariDal.Update(jadwal); } tran.Complete(); } }
public LayananModel GetById(string id) { LayananModel retVal = _layananBL.GetById(id); return(retVal); }