public ActionResult Create(int gpid)
 {
     HoSoGiayPhep hs = _gphdRepository.GetHoSoGiayPhepByID(gpid);
     BaoCaoHoatDong bc = new BaoCaoHoatDong();
     bc = hs.ThongTinChung.BaoCaoHoatDongs.SingleOrDefault(m => m.MaThongTinChung == hs.MaThongTinChung);
     int k = 0;
     if (bc != null)
     {
         k = bc.MaBaoCao;
     }
     var dangky = _dkhdRespository.GetDangKyHDs(gpid);
     var hdDaCap = _dkhdRespository.GetDKHDDaCap(gpid);
     var hdBoSung = _dkhdRespository.GetDKHDBoSung(gpid);
     var maHDList = _dkhdRespository.getSelectedHD(dangky.ToList<DangKyHoatDong>());
     var hoatdongList = new List<HoatDong>();
     foreach (int i in maHDList)
     {
         hoatdongList.Add(_hoatdongRespository.GetHoatDongByID(i));
     }
     var gpchitiet = new GiayPhepDetailModel
     {
         DangKy = dangky,
         giayphep = hs,
         hoatdong = hoatdongList,
         DangKyDaCap = hdDaCap,
         DangKyBoSung = hdBoSung,
         MaBaoCao = k
         // nangluc = nanglucList
     };
     var td = _thamdinhRepository.GetThamDinhByGPID(gpid);
     if (td == null)
     {
         td = new ThamDinh();
     }
     ThamDinhEditViewModel model = new ThamDinhEditViewModel();
     model.giayphep = _gphdRepository.GetHoSoGiayPhepByID(gpid);
        // model.SoGiayPhep = model.giayphep.SoGiayPhep;
     model.thongtinchung = gpchitiet;
     model.ThamDinh = td;
     //model.m = gpid;
     return View(model);
 }
        public ActionResult Edit(int gpid)
        {
            HoSoGiayPhep hs = _gphdRepository.GetHoSoGiayPhepByID(gpid);
            ThamDinh td = _thamdinhRepository.GetThamDinhByGPID(hs.MaHoSo);
            if (td != null && td.TinhTrangThamDinh == true)
            {
                return RedirectToAction("thongbao", new { iMsg = true});
            }
            BaoCaoHoatDong bc = new BaoCaoHoatDong();
            bc = hs.ThongTinChung.BaoCaoHoatDongs.SingleOrDefault(m => m.MaThongTinChung == hs.MaThongTinChung);

            var dangky = _dkhdRespository.GetDangKyHDs(gpid);
            var hdDaCap = _dkhdRespository.GetDKHDDaCap(gpid);
            var hdBoSung = _dkhdRespository.GetDKHDBoSung(gpid);
            var maHDList = _dkhdRespository.getSelectedHD(dangky.ToList<DangKyHoatDong>());
            var hoatdongList = new List<HoatDong>();
            foreach (int i in maHDList)
            {
                hoatdongList.Add(_hoatdongRespository.GetHoatDongByID(i));
            }
            var gpchitiet = new GiayPhepDetailModel
            {
                DangKy = dangky,
                giayphep = hs,
                hoatdong = hoatdongList,
                DangKyDaCap = hdDaCap,
                DangKyBoSung = hdBoSung,
                MaBaoCao = bc == null ? 0 : bc.MaBaoCao
                // nangluc = nanglucList
            };
            //            var td = _thamdinhRepository.GetThamDinhByGPID(gpid);
            ThamDinhEditViewModel model = new ThamDinhEditViewModel();
            model.giayphep = _gphdRepository.GetHoSoGiayPhepByID(gpid);
            model.thongtinchung = gpchitiet;
            model.ThamDinh = td;
            model.ThamDinh.NguoiThamDinh = model.ThamDinh.NguoiThamDinh.Replace(";", System.Environment.NewLine);
            model.ThamDinh.NguoiPhiaToChuc = model.ThamDinh.NguoiPhiaToChuc.Replace(";", System.Environment.NewLine);
            //model.m = gpid;
            return View(model);
        }
 public ActionResult ChiTiet()
 {
     TaiKhoan tk = ((EnhancedPrincipal)HttpContext.User).Data;
     int id = tk.MaTaiKhoan;
     List<ToChuc> tcs = tk.ToChucs.ToList();
     if (tcs.Count == 0)
     {
         return RedirectToAction("ThongBao", new { iMsg = 14 });
     }
     ToChuc tc = tcs[0];
     HoSoGiayPhep gphd = _hsgpRepository.GetHSGPByToChucId(tc.MaToChuc);
     BaoCaoHoatDong bc = new BaoCaoHoatDong();
     bc = gphd.ThongTinChung.BaoCaoHoatDongs.SingleOrDefault(m=>m.MaThongTinChung == gphd.MaThongTinChung);
     int k = 0;
     if (bc != null)
     {
         k = bc.MaBaoCao;
     }
     var dangkyMoi = _dkhdRespository.GetDangKyHDMoi(id);
     var dangkyDuocCap = _dkhdRespository.GetDKHDDaCap(id);
     var dangkyBS = _dkhdRespository.GetDKHDBoSung(id);
     var model = new GiayPhepDetailModel
     {
         DangKy = dangkyMoi,
         DangKyDaCap = dangkyDuocCap,
         DangKyBoSung = dangkyBS,
         giayphep = gphd,
         MaBaoCao = k
         //hoatdong = hoatdongList
        // nangluc = nanglucList
     };
     return View(model);
 }
 // GET: /ThamDinh/Details/5
 public ActionResult Detail(int gpid)
 {
     //ThamDinh thamdinh = new ThamDinh();
     HoSoGiayPhep hs = _gphdRepository.GetHoSoGiayPhepByID(gpid);
     BaoCaoHoatDong bc = new BaoCaoHoatDong();
     bc = hs.ThongTinChung.BaoCaoHoatDongs.SingleOrDefault(m => m.MaThongTinChung == hs.MaThongTinChung);
     var dangky = _dkhdRespository.GetDangKyHDs(gpid);
     var hdDaCap = _dkhdRespository.GetDKHDDaCap(gpid);
     var hdBoSung = _dkhdRespository.GetDKHDBoSung(gpid);
     var maHDList = _dkhdRespository.getSelectedHD(dangky.ToList<DangKyHoatDong>());
     var hoatdongList = new List<HoatDong>();
     foreach (int i in maHDList)
     {
         hoatdongList.Add(_hoatdongRespository.GetHoatDongByID(i));
     }
     var gpchitiet = new GiayPhepDetailModel
     {
         DangKy = dangky,
         giayphep = hs,
         hoatdong = hoatdongList,
         DangKyDaCap = hdDaCap,
         DangKyBoSung = hdBoSung,
         MaBaoCao = (bc == null? 0 : bc.MaBaoCao)
         // nangluc = nanglucList
     };
     ThamDinh thamdinh = _thamdinhRepository.GetThamDinhByGPID(gpid);
     var viewmodel = new ThamDinhEditViewModel { ThamDinh = thamdinh, giayphep =hs, thongtinchung = gpchitiet };
     return View(viewmodel);
 }
 public ActionResult ChiTiet(int id)
 {
     HoSoGiayPhep gphd = _gphdRepository.GetHoSoGiayPhepByID(id);
     if (gphd == null)
     {
         return RedirectToAction("ThongBao", new {iMsg = 2});
     }
     BaoCaoHoatDong bc = new BaoCaoHoatDong();
     bc = gphd.ThongTinChung.BaoCaoHoatDongs.SingleOrDefault(m=>m.MaThongTinChung == gphd.MaThongTinChung);
     int k = 0;
     if (bc != null)
     {
         k = bc.MaBaoCao;
     }
     var dangkyMoi = _dkhdRespository.GetDangKyHDMoi(id);
     var dangkyDuocCap = _dkhdRespository.GetDKHDDaCap(id);
     var dangkyBS = _dkhdRespository.GetDKHDBoSung(id);
     var model = new GiayPhepDetailModel
     {
         DangKy = dangkyMoi,
         DangKyDaCap = dangkyDuocCap,
         DangKyBoSung = dangkyBS,
         giayphep = gphd,
         MaBaoCao = k
         //hoatdong = hoatdongList
        // nangluc = nanglucList
     };
     return View(model);
 }