private async Task <Tuple <int, string> > CallSetup(ModifyForumRolesType modifyType) { var service = GetService(); var forum = new Forum { ForumID = 123 }; var role = "role"; _mockForumRepo.Setup(x => x.Get(forum.ForumID)).ReturnsAsync(forum); await service.ModifyForumRoles(new ModifyForumRolesContainer { ForumID = forum.ForumID, ModifyType = modifyType, Role = role }); return(Tuple.Create(forum.ForumID, role)); }
private void CallSetup(ModifyForumRolesType modifyType, out int forumID, out string role) { var service = GetService(); var forum = new Forum { ForumID = 123 }; forumID = forum.ForumID; role = "role"; _mockForumRepo.Setup(x => x.Get(forum.ForumID)).Returns(forum); service.ModifyForumRoles(new ModifyForumRolesContainer { ForumID = forum.ForumID, ModifyType = modifyType, Role = role }); }
public EmptyResult ModifyForumRoles(int forumID, ModifyForumRolesType modifyType, string role = null) { var forum = _forumService.Get(forumID); if (forum == null) { throw new Exception(String.Format("ForumID {0} not found.", forumID)); } switch (modifyType) { case ModifyForumRolesType.AddPost: _forumService.AddPostRole(forum, role); break; case ModifyForumRolesType.RemovePost: _forumService.RemovePostRole(forum, role); break; case ModifyForumRolesType.AddView: _forumService.AddViewRole(forum, role); break; case ModifyForumRolesType.RemoveView: _forumService.RemoveViewRole(forum, role); break; case ModifyForumRolesType.RemoveAllPost: _forumService.RemoveAllPostRoles(forum); break; case ModifyForumRolesType.RemoveAllView: _forumService.RemoveAllViewRoles(forum); break; default: throw new Exception("ModifyForumRoles doesn't know what to do."); } return(new EmptyResult()); }
public EmptyResult ModifyForumRoles(int forumID, ModifyForumRolesType modifyType, string role = null) { var forum = _forumService.Get(forumID); if (forum == null) throw new Exception(String.Format("ForumID {0} not found.", forumID)); switch (modifyType) { case ModifyForumRolesType.AddPost: _forumService.AddPostRole(forum, role); break; case ModifyForumRolesType.RemovePost: _forumService.RemovePostRole(forum, role); break; case ModifyForumRolesType.AddView: _forumService.AddViewRole(forum, role); break; case ModifyForumRolesType.RemoveView: _forumService.RemoveViewRole(forum, role); break; case ModifyForumRolesType.RemoveAllPost: _forumService.RemoveAllPostRoles(forum); break; case ModifyForumRolesType.RemoveAllView: _forumService.RemoveAllViewRoles(forum); break; default: throw new Exception("ModifyForumRoles doesn't know what to do."); } return new EmptyResult(); }