public List <GameAuthority> gameAuthorities => gameClubEntities.GameAuthority.ToList();//获取社团所有职位信息 /// <summary> /// 添加职权信息 /// </summary> /// <param name="gameAuthority"></param> /// <returns>返回0代表出现重复数据,返回1表示添加成功</returns> public int addGameAuthority(GameAuthority gameAuthority) { GameAuthority gameAuthorityResult = gameClubEntities.GameAuthority.Where(ga => ga.Number == gameAuthority.Number).FirstOrDefault(); if (gameAuthorityResult == null) { gameClubEntities.GameAuthority.Add(gameAuthority); gameClubEntities.SaveChanges(); EFUserRecord.AddUserOperateRecord("添加了" + gameAuthority.AuthorityString + "的社团权限"); return(1); } else { return(0); } }
/// <summary> /// 更新职位信息 /// </summary> /// <param name="gameAuthority"></param> /// <returns></returns> public ActionResult UpdateAuthority(GameAuthority gameAuthority) { DealViewBag("GameNumberAuthority"); TempData["ShowNumber"] = gameAuthority.Number; if (ModelState.IsValid) { if (EFGameMember.updateGameAuthority(gameAuthority) == 1) { TempData["Success"] = "修改成功!"; } else { TempData["Fault"] = "修改失败,不存在此编号!"; } } else { TempData["Fault"] = "修改失败,请检查输入!"; } return(View("Authority", EFGameMember.gameAuthorities)); }
/// <summary> /// 删除职位信息 /// </summary> /// <param name="number"></param> /// <returns>"0"表示未找到该职位信息,“1”表示删除成功</returns> public int deleteGameAuthority(int number) { GameAuthority gameAuthority = gameClubEntities.GameAuthority.Where(ga => ga.Number == number).FirstOrDefault(); if (gameAuthority != null) { if (gameClubEntities.GameMember.Where(g => g.Authority == number) == null) { gameClubEntities.GameAuthority.Remove(gameAuthority); gameClubEntities.SaveChanges(); EFUserRecord.AddUserOperateRecord("删除了" + gameAuthority.AuthorityString + "的社团权限"); return(1); } else { return(0); } } else { return(0); } }
/// <summary> /// 添加职位信息 /// </summary> /// <param name="gameAuthority"></param> /// <returns></returns> public ActionResult AddAuthority(GameAuthority gameAuthority) { DealViewBag("GameNumberAuthority"); TempData["ShowAdd"] = gameAuthority.Number; if (ModelState.IsValid) { if (EFGameMember.addGameAuthority(gameAuthority) == 1) { TempData["Success"] = "添加成功!"; TempData["ShowNumber"] = gameAuthority.Number; TempData["ShowAdd"] = null; } else { TempData["Fault"] = "已存在相同编号的职位!"; } } else { TempData["Fault"] = "请检查输入!"; } return(View("Authority", EFGameMember.gameAuthorities)); }