public ActionResult Create(PermisstionObject ob, FormCollection collection) { try { // TODO: Add insert logic here if (ob != null) { ob.PerID = Guid.NewGuid(); var i = new PermisstionBCL().GetJoinCheck((Guid)ob.UserId, ob.FeaId); if (i.Count > 0) { ModelState.AddModelError("", "Người dùng đã tồn tại quyền này"); } else { if (new PermisstionBCL().Insert(ob)) { return(RedirectToAction("Index")); } } } } catch { } return(View()); }
public ActionResult Index(FormCollection f) { var result = new PermisstionBCL().GetJoin(); Guid UserId = new Guid(); string FeaId = null; if (f["UserId"] != null && Guid.TryParse(f["UserId"].ToString(), out UserId)) { ViewBag.UserId = UserId; result = result.Where(q => q.UserId == UserId).ToList(); } if (f["FeaId"] != null && !string.IsNullOrWhiteSpace(f["FeaId"].ToString())) { FeaId = f["FeaId"].ToString(); ViewBag.FeaId = FeaId; result = result.Where(q => q.FeaId.Trim().ToLower() == FeaId.Trim().ToLower()).ToList(); } return(View(result)); }