public ApprovalTypeModel Add(ApprovalTypeModel approvalType) { // INPUT VALIDATION var kt = Validate(approvalType); // BUSINESS VALIDATION var approvalTypeDb = _approvalTypeDal.GetData(kt); approvalTypeDb.NotEmpty().Throw("APPROVAL TYPE ID already exist"); // REPO-OP _approvalTypeDal.Insert(kt); // RETURN return(kt); }
public void GetData_Test() { using (var trans = TransHelper.NewScope()) { // arrange var expected = ApprovalTypeTestData(); _sut.Insert(expected); // act var actual = _sut.GetData(expected); // assert actual.Should().BeEquivalentTo(expected); } }
private SuratDinasModel Validate(SuratDinasModel sd) { // mandatory check sd.JenisBiayaID.Empty().Throw("JENIS BIAYA kosong"); sd.PegID.Empty().Throw("PEGAWAI kosong"); sd.RSID.Empty().Throw("RS TUJUAN kosong"); sd.TransportID.Empty().Throw("TRANSPORT kosong"); sd.Keperluan.Empty().Throw("KEPERLUAN kosong"); // pegawai var peg = _pegDal.GetData(sd); peg.Empty().Throw("PEGAWAI invalid"); sd.PegName = peg.PegName; // transport var transport = _transportDal.GetData(sd); transport.Empty().Throw("TRANSPORT invalid"); sd.TransportName = transport.TransportName; // jenis biaya var jb = _jenisBiayaDal.GetData(sd); jb.Empty().Throw("JENIS BIAYA invalid"); sd.JenisBiayaName = jb.JenisBiayaName; // rumah sakit var rs = _rsDal.GetData(sd); rs.Empty().Throw("RS TUJUAN invalid"); sd.RSName = rs.RSName; // urutan tgl mulai - selesai sd.TglSelesai.LessThan(sd.TglMulai).Throw("Tgl Mulasi / Selesai invalid"); // km awal => terisi jika mobil kantor, kosong jika sebaliknya if (sd.TransportID == TRANSPORT_ID_OPERASIONAL) { sd.KMAwal.LessOrEqual(0).Throw("KM Awal kosong"); } if (sd.TransportID != TRANSPORT_ID_OPERASIONAL) { sd.KMAwal = 0; } // nilai kas bon => terisi jika kasbon, kosongkan jika bukan kasbon if (sd.JenisBiayaID == JENISBIAYA_ID_KASBON) { sd.KasBon.LessOrEqual(0).Throw("Nilai KasBon kosong"); } if (sd.JenisBiayaID != JENISBIAYA_ID_KASBON) { sd.KasBon = 0; } // approval sd.ListApproval.Empty().Throw("List Approval empty"); var listApproval = new List <SuratDinasApprovalModel>(); foreach (var item in sd.ListApproval) { peg = _pegDal.GetData(item); peg.Empty().Throw("PegID Approval invalid"); item.PegName = peg.PegName; var aprvType = _approvalTypeDal.GetData(item); aprvType.Empty().Throw("Approval Type invalid"); item.ApprovalTypeName = aprvType.ApprovalTypeName; var newItem = new SuratDinasApprovalModel { PegID = item.PegID, PegName = peg.PegName, ApprovalTypeID = item.ApprovalTypeID, ApprovalTypeName = item.ApprovalTypeName, }; listApproval.Add(newItem); } sd.ListApproval = listApproval; return(sd); }