// GET: UserManager public ActionResult Index(int?page) { // Show message if (Session["mes"] != null) { ViewBag.message = Session["mes"]; Session.Remove("mes"); } if (Session["mes_er"] != null) { ViewBag.message_er = Session["mes_er"]; Session.Remove("mes_er"); } ViewBag.Active = "manager"; CustomPrincipal prin = (CustomPrincipal)User; IPagedList ListUser = null; if (prin.ROLE.Equals(ConstanAppkey.ADMIN())) { ListUser = userModels.GetItems(page ?? 1, ConstanAppkey.PAGESIZE()); } else if (prin.ROLE.Equals(ConstanAppkey.MOD())) { ListUser = userModels.GetItemsMod(page ?? 1, ConstanAppkey.PAGESIZE(), prin); } return(View(ListUser)); }
public bool checkUserAdd(USER userCheck) { ROLE Role = roleModels.GetItem(userCheck.ID_ROLE); if (prin.ROLE.Equals(ConstanAppkey.ADMIN())) { if (!Role.NAME.Equals(ConstanAppkey.ADMIN())) { return(true); } } else if (prin.ROLE.Equals(ConstanAppkey.MOD())) { if (Role.NAME.Equals(ConstanAppkey.USER())) { return(true); } } return(false); }
public bool checkPostDelete(POST postCheck) { ROLE Role = roleModels.GetItem(postCheck.USER.ID_ROLE); if (postCheck.USER.ID == prin.ID) { return(true); } if (prin.ROLE.Equals(ConstanAppkey.ADMIN())) { return(true); } else if (prin.ROLE.Equals(ConstanAppkey.MOD())) { if (Role.NAME.Equals(ConstanAppkey.USER())) { return(true); } } return(false); }
public ActionResult Edit(int id, POST Post, FormCollection form, HttpPostedFileBase PICTURE) { CustomPrincipal prin = (CustomPrincipal)User; if (ModelState.IsValid) { POST PostEdit = postsModels.GetItem(id); string picture_old = ""; string picture_new = ""; //upload file if (PICTURE != null && PICTURE.ContentLength > 0) { var path = Server.MapPath("~/Assets/Upload/Post/"); ImgUpload imgUpload = new ImgUpload(); Post.PICTURE = imgUpload.Upload(PICTURE, path); picture_new = Post.PICTURE; picture_old = PostEdit.PICTURE; } else { Post.PICTURE = PostEdit.PICTURE; } if (this.Request.Form["ACTIVE"] != null) { Post.ACTIVE = true; } else { if (prin.ROLE.Equals(ConstanAppkey.ADMIN()) || prin.ROLE.Equals(ConstanAppkey.MOD())) { Post.ACTIVE = false; } else { Post.ACTIVE = PostEdit.ACTIVE; } } int idPosst = postsModels.EditItem(id, Post); if (idPosst > 0) { if (!picture_old.Equals("")) { var dataFile = Server.MapPath("~/Assets/Upload/Post/" + picture_old); ImgUpload imgUpload = new ImgUpload(); imgUpload.Delete(dataFile); } Session["mes"] = "Sửa thành công"; } else { if (!picture_new.Equals("")) { var dataFile = Server.MapPath("~/Assets/Upload/Post/" + picture_new); ImgUpload imgUpload = new ImgUpload(); imgUpload.Delete(dataFile); } Session["mes_er"] = "Sửa thất bại"; } return(RedirectToAction("Index", "PostManager")); } ViewBag.ListCategories = categoriesModels.GetAllItem(); return(View(Post)); }