//將選取的對象加入黑名單 public string intoblacklist(int memberid, string blackreason) { var goblacklist = CMemberFactory.fn會員查詢().FirstOrDefault(g => g.fMemberId == memberid); if (goblacklist.fIsBanned == true)//判斷是否已經是黑名單 避免重複加入黑名單 { ViewBag.blacklist = "此會員已是黑名單會員"; return("已是黑名單成員"); } else { goblacklist.fIsBanned = true; CMemberFactory.fn會員更新(goblacklist); CBlackListFactory.fn黑名單新增(new CBlackList() { fLockDateTime = DateTime.UtcNow.AddHours(08), fMemberId = memberid, fReason = blackreason }); CNotice c = new CNotice(); c.fNoticeDatetime = DateTime.Now; c.fNoticeContent = "此帳號因發言屢次違規已被設為黑名單,期間內無法針對商品進行留言"; c.fCategoryType = "管理員"; c.fLink = "超連結"; c.fMemberId = goblacklist.fMemberId; CNoticeFactory.fn通知訂單訊息新增(c); return("黑名單更新成功!"); } }
//黑名單頁面 public ActionResult BlackList() { CAdmin admin = Session[CAdminSession.Session_Login_User] as CAdmin; if (admin == null) { return(RedirectToAction("../Member/AdminLogin")); } var blacklist = CBlackListFactory.fn黑名單查詢().ToList(); return(View(blacklist)); }
//將選取的對象解除黑名單 public string unlockBlacklist(int bannid, int memberid) { CAdmin admin = Session[CAdminSession.Session_Login_User] as CAdmin; List <CBlackList> blacklist = new List <CBlackList>(); var unlock = CBlackListFactory.fn黑名單查詢().FirstOrDefault(m => m.fBannedId == bannid); var member = CMemberFactory.fn會員查詢().FirstOrDefault(n => n.fMemberId == memberid); member.fIsBanned = false; CMemberFactory.fn會員更新(member); CBlackListFactory.fn黑名單刪除(unlock); CNotice c = new CNotice(); c.fNoticeDatetime = DateTime.UtcNow.AddHours(08); c.fNoticeContent = "此帳號已從黑名單解鎖"; c.fCategoryType = "管理員"; c.fLink = "超連結"; c.fMemberId = member.fMemberId; CNoticeFactory.fn通知訂單訊息新增(c); return("解鎖成功!"); }