// [Audit]
        public async Task <ActionResult> Delete(PhieuKiemKe pkk)
        {
            if (pkk == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var maNhaThuoc  = this.GetNhaThuoc().MaNhaThuoc;
            var phieuKiemKe =
                await
                unitOfWork.PhieuKiemKeRepository.GetMany(
                    e => e.NhaThuoc.MaNhaThuoc == maNhaThuoc && e.MaPhieuKiemKe == pkk.MaPhieuKiemKe).FirstOrDefaultAsync();

            if (phieuKiemKe == null)
            {
                return(HttpNotFound());
            }
            // delete
            if (phieuKiemKe.PhieuNhap != null)
            {
                var service    = IoC.Container.Resolve <IReceiptNoteService>();
                var noteTypeId = service.DeleteReceiptNote(MedSessionManager.CurrentDrugStoreCode, phieuKiemKe.PhieuNhap.MaPhieuNhap, MedSessionManager.CurrentUserId);
            }
            //unitOfWork.PhieuNhapRepository.Delete(phieuKiemKe.PhieuNhap);
            if (phieuKiemKe.PhieuXuat != null)
            {
                var service    = IoC.Container.Resolve <IDeliveryNoteService>();
                var noteTypeId = service.DeleteDeliveryNote(MedSessionManager.CurrentDrugStoreCode, phieuKiemKe.PhieuXuat.MaPhieuXuat, MedSessionManager.CurrentUserId);
            }

            unitOfWork.PhieuKiemKeRepository.Delete(phieuKiemKe);
            unitOfWork.Save();
            return(RedirectToAction("index"));
        }
Ejemplo n.º 2
0
 public PhieuKiemKeEditModel(PhieuKiemKe phieuKiemKe)
 {
     MaPhieuKiemKe = phieuKiemKe.MaPhieuKiemKe;
     SoPhieu       = phieuKiemKe.SoPhieu;
     if (phieuKiemKe.Created.HasValue)
     {
         NgayTao = phieuKiemKe.Created.Value;
     }
     Items = new List <PhieuKiemKeItemEditModel>();
     if (phieuKiemKe.PhieuKiemKeChiTiets != null && phieuKiemKe.PhieuKiemKeChiTiets.Any())
     {
         phieuKiemKe.PhieuKiemKeChiTiets.ForEach(e =>
         {
             Items.Add(new PhieuKiemKeItemEditModel()
             {
                 TenNhomThuoc       = e.Thuoc.NhomThuoc.TenNhomThuoc,
                 MaThuoc            = e.Thuoc.MaThuoc,
                 SoLuongThucTe      = e.ThucTe,
                 SoLuongHeThong     = e.TonKho,
                 TenThuoc           = e.Thuoc.TenThuoc,
                 TenDonViTinhXuatLe = e.Thuoc.DonViXuatLe.TenDonViTinh
             });
         });
     }
 }