public void AddCTPM(ChiTietPhieuMuonDTO ctpmDTO)
        {
            var ctpm = ctpmDTO.MappingCTPM();
            var sach = sachRepository.GetBy(ctpmDTO.MaSach);

            sach.TrangThaiSach = "Đã mượn";
            sachRepository.Update(sach);
            var pm = phieumuonRepository.GetBy(ctpm.MaPM);

            ctpm.PhiMuon   = (int)(sach.GiaBia * 0.2);
            pm.TongPhiMuon = pm.TongPhiMuon + ctpm.PhiMuon;
            phieumuonRepository.Update(pm);
            chiTietPhieuMuonRepository.Add(ctpm);
        }
        public void AddCTPP(ChiTietPhieuPhatDTO ctppDTO)
        {
            var ctpp      = ctppDTO.MappingCTPP();
            var sach      = sachRepository.GetBy(ctppDTO.MaSach);
            var phieuphat = phieuphatRepository.GetBy(ctppDTO.MaPP);

            if (ctpp.NoiDungViPham == "Trễ hạn sách")
            {
                ctpp.PhiPhat += (int)(sach.GiaBia * 0.2);
            }
            if (ctpp.NoiDungViPham == "Hư sách")
            {
                ctpp.PhiPhat += (int)(sach.GiaBia * 0.3);
            }
            if (ctpp.NoiDungViPham == "Mất sách")
            {
                ctpp.PhiPhat += (int)(sach.GiaBia * 1.2);
            }

            phieuphat.TongPhiPhat += ctpp.PhiPhat;


            chiTietPhieuPhatRepository.Add(ctpp);
            phieuphatRepository.Update(phieuphat);
        }
Exemple #3
0
        public SachDTO GetSach(int maS)
        {
            var sach = _sachRepository.GetBy(maS);

            return(sach.MappingSachDto());
        }