public async Task <IActionResult> CreateBBS(MoBBSInfo moBBS) { if (!HttpContext.TryGetUserInfo(out var userInfo)) { this.MsgBox("登录已过期,请重新登录"); return(View()); } ViewData["Id"] = userInfo.Id; ViewData["UserName"] = userInfo.UserName; ViewData["HeadPhoto"] = userInfo.HeadPhoto; ViewData["Role"] = userInfo.Roles.ToLower(); if (!ModelState.IsValid) { this.MsgBox("验证论坛信息失败,请重试"); return(View()); } if (String.IsNullOrWhiteSpace(moBBS.BBSName)) { this.MsgBox("论坛名称不可为空!"); return(View()); } var isExsit = _uf.BBSRepository.IsExist(x => x.Bbstype == moBBS.BBSType && x.Bbsname.Equals(moBBS.BBSName, StringComparison.OrdinalIgnoreCase)); if (isExsit) { this.MsgBox("该论坛已存在,请不要重复创建"); return(View()); } var bbs = new Bbs { UserId = userInfo.Id, Bbsname = moBBS.BBSName, Bbstype = moBBS.BBSType }; await _uf.BBSRepository.InsertAsync(bbs); var result = await _uf.SaveChangesAsync(); if (result <= 0) { this.MsgBox("创建论坛失败"); return(View()); } BBSList.FreshBBSList(_uf); this.MsgBox($"恭喜你,创建论坛【{moBBS.BBSName}】成功"); return(View()); }
public IActionResult GetBBSList() { bool result; IList <MoBBSItem> bbsList = null; try { using (_uf) { bbsList = BBSList.GetCurrentList(_uf); } result = true; } catch { result = false; } return(Json(new MoData { IsOk = result, Data = bbsList })); }