public JsonResult LayDanhSachQuyenHan(string maNghiepVu, string maNhanVien) { var danhSachDaChia = bll.DanhSachPhanQuyenDaGan(maNhanVien, maNghiepVu).ToList(); var danhSachQuyenHan = bll.DanhSachTatCaQuyenHanCuaNghiepVu(maNghiepVu); var danhSachMaQuyenHan = danhSachDaChia.Select(x => x.MaQuyenHan); //So sánh xem permission của business mà chưa có trong list granted thì gán vào (isgrant=false) foreach (var item in danhSachQuyenHan) { if (!danhSachMaQuyenHan.Contains(item.MaQuyenHan)) { danhSachDaChia.Add(item); } } List <PhanQuyenModel> lst = new List <PhanQuyenModel>(); foreach (var item in danhSachDaChia) { PhanQuyenModel pmd = new PhanQuyenModel { MaQuyenHan = item.MaQuyenHan, TenQuyenHan = item.TenQuyenHan, DaDuocChon = item.DaDuocChon, MoTa = item.MoTa }; lst.Add(pmd); } return(Json(new { data = lst }, JsonRequestBehavior.AllowGet)); }
public async Task <IActionResult> Edit(int id, [Bind("MaQuyen,TenQuyen,TrangThai")] PhanQuyenModel phanQuyenModel) { if (id != phanQuyenModel.MaQuyen) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(phanQuyenModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PhanQuyenModelExists(phanQuyenModel.MaQuyen)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(phanQuyenModel)); }
public async Task <IActionResult> Create([Bind("MaQuyen,TenQuyen,TrangThai")] PhanQuyenModel phanQuyenModel) { if (ModelState.IsValid) { _context.Add(phanQuyenModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(phanQuyenModel)); }
public List <PhanQuyenModel> layDSQuyen(string maNhom) { var phanquyen = from pq in db.PhanQuyens join mh in db.ManHinhs on pq.MaMH equals mh.MaManHinh where pq.MaNhom == maNhom select new { pq.MaMH, mh.TenMH, pq.CoQuyen }; List <PhanQuyenModel> ds = new List <PhanQuyenModel>(); foreach (var item in phanquyen) { PhanQuyenModel model = new PhanQuyenModel(); model.MaMH = item.MaMH; model.TenMH = item.TenMH; model.Quyen = item.CoQuyen; ds.Add(model); } return(ds); }
public ActionResult Index(string ddlVaiTro) { //Load selected list vai trò LoadViewBag(); //Kiểm tra vai trò if (string.IsNullOrEmpty(ddlVaiTro)) { return(View()); } int vaitroId = -1; int.TryParse(ddlVaiTro, out vaitroId); List <PhanQuyenModel> lst = new List <PhanQuyenModel>(); if (vaitroId > 0) { //Lấy tất cả chức năng var lstChucNang = DataProvider.Entities.ChucNangs.ToList(); foreach (var item in lstChucNang) { PhanQuyenModel obj = new PhanQuyenModel(); if (CheckQuyenDaCap(vaitroId, item.Id)) //chức năng đã đc cấp { obj.Id = item.Id; obj.TenChucNang = item.TenChucNang; obj.CapChucNang = true; lst.Add(obj); } else //chức năng chưa được cấp { obj.Id = item.Id; obj.TenChucNang = item.TenChucNang; obj.CapChucNang = false; lst.Add(obj); } } } return(View(lst)); }