public ActionResult Index(FormCollection collection) { var index_view = new Index_view(); this.TryUpdateModel(index_view); if (!this.CheckAdminlogin()) { return(this.RedirectToAction("login", "dashboard", new { area = "admin", return_url = index_view.Return_url })); } else { if (index_view.Act == string.Empty || index_view.Ctrl == string.Empty) { index_view.Act = "access_denied"; index_view.Ctrl = "dashboard"; } return(this.PartialView("../page/index", index_view)); } }
public ActionResult Index() { if (!this.CheckAdminlogin()) { return(this.RedirectToAction("login", "dashboard", new { area = "admin" })); } else { var return_url = Request.Url.ToString(); var index_view = new Index_view(); int count = Request.QueryString.Count; if (count > 0) { string act, ctrl, type_act, type; act = Request.QueryString["act"] != null ? Request.QueryString["act"].ToString() : string.Empty; ctrl = Request.QueryString["ctrl"] != null ? Request.QueryString["ctrl"].ToString() : string.Empty; type_act = Request.QueryString["type_act"] != null ? Request.QueryString["type_act"].ToString() : CommonGlobal.View; type = Request.QueryString["type"] != null ? Request.QueryString["type"].ToString() : string.Empty; if (act != string.Empty && ctrl != string.Empty) { bool isOk = false; UserModels sv = new UserModels(); RoleModels roleM = new RoleModels(); C_Role itR = new C_Role(); C_User itU = new C_User(); itU = sv.GetUserbyUserName(Session["mem"].ToString()); itR = roleM.GetRoleItem(itU.Role); ////check permission view/add/edit if (ctrl == "adminProduct" && (act == "image_product" || act == "property_product" || act == "list_Rating")) { ////Chỉ được phép thay đổi thuộc tính của sản phẩm nếu có quyền edit product if (UserModels.CheckPermission(this.Session["mem"] != null ? this.Session["mem"].ToString() : string.Empty, "change_product", ctrl, type_act, type) && itR.Role == "Admin") { isOk = true; } else { isOk = false; } } else { if (UserModels.CheckPermission(this.Session["mem"] != null ? this.Session["mem"].ToString() : string.Empty, act, ctrl, type_act, type) && itR.Role == "Admin") { isOk = true; } else { isOk = false; } } if (isOk == true) { index_view.Act = act; index_view.Ctrl = ctrl; index_view.Type_act = type_act; index_view.Type = type; } else { logger.Error(Session["mem"].ToString() + " đã truy cập khu vực không hợp lệ:act = " + act + ",ctrl = " + ctrl + ",type_act= " + type_act + ",type= " + type); index_view.Act = "access_denied"; index_view.Ctrl = "dashboard"; } } else { logger.Error(Session["mem"].ToString() + " đã truy cập khu vực không hợp lệ:act = " + act + ",ctrl = " + ctrl + ",type_act= " + type_act + ",type= " + type); index_view.Act = "access_denied"; index_view.Ctrl = "dashboard"; } } else { index_view.Act = "statistic"; index_view.Ctrl = "dashboard"; index_view.Type_act = CommonGlobal.View; index_view.Type = string.Empty; } index_view.Return_url = return_url; return(this.PartialView("../page/index", index_view)); } }