/// <summary> /// 屏蔽群组 /// </summary> /// <param name="spaceKey">空间名</param> /// <returns>屏蔽群组名</returns> public ActionResult _BlockGroups(string spaceKey) { long userId = UserIdToUserNameDictionary.GetUserId(spaceKey); if (UserContext.CurrentUser == null || (UserContext.CurrentUser.UserId != userId && new Authorizer().IsAdministrator(new TenantTypeService().Get(TenantTypeIds.Instance().Group()).ApplicationId))) { return(Content(string.Empty)); } IEnumerable <UserBlockedObject> blockedGroups = new UserBlockService().GetBlockedGroups(userId); List <UserBlockedObjectViewModel> blockedObjectes = new List <UserBlockedObjectViewModel>(); if (blockedGroups != null && blockedGroups.Count() > 0) { groupService.GetGroupEntitiesByIds(blockedGroups.Select(n => n.ObjectId)); foreach (var item in blockedGroups) { GroupEntity group = groupService.Get(item.ObjectId); if (group == null) { continue; } UserBlockedObjectViewModel entitiy = item.AsViewModel(); entitiy.Logo = group.Logo; blockedObjectes.Add(entitiy); } } return(View(blockedObjectes)); }
public ActionResult BlockGroups(string spaceKey, List <long> groupIds) { int addCount = 0; long userId = UserIdToUserNameDictionary.GetUserId(spaceKey); UserBlockService service = new UserBlockService(); if (userId > 0 && groupIds != null && groupIds.Count > 0) { foreach (var groupId in groupIds) { GroupEntity group = groupService.Get(groupId); if (group == null || service.IsBlockedGroup(userId, groupId)) { continue; } service.BlockGroup(userId, group.GroupId, group.GroupName); addCount++; } } if (addCount > 0) { TempData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Success, string.Format("成功添加{0}个群组添加到屏蔽列表", addCount)); } else { TempData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Error, "没有任何群组被添加到屏蔽列表中"); } return(Redirect(SiteUrls.Instance().BlockGroups(spaceKey))); }
public ActionResult BlockTopics(string spaceKey, List <long> topicIds) { int addCount = 0; long userId = UserIdToUserNameDictionary.GetUserId(spaceKey); UserBlockService service = new UserBlockService(); if (userId > 0 && topicIds != null && topicIds.Count > 0) { foreach (var topicId in topicIds) { TopicEntity topic = topicService.Get(topicId); if (topic == null || service.IsBlockedTopic(userId, topicId)) { continue; } service.BlockTopic(userId, topic.TopicId, topic.TopicName); addCount++; } } if (addCount > 0) { TempData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Success, string.Format("成功添加{0}个专题添加到屏蔽列表", addCount)); } else { TempData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Error, "没有任何专题被添加到屏蔽列表中"); } return(Redirect(SiteUrls.Instance().BlockGroups(spaceKey))); }
public static IEnumerable <UserBlockedObject> GetBlockedTopics(this UserBlockService blockservice, long userId) { throw new Exception(); return(null); }
public static bool IsBlockedTopic(this UserBlockService block, long userId, long checkingTopicId) { throw new Exception(); return(false); }
public static bool BlockTopic(this UserBlockService blockservice, long userId, long blockedGroupId, string blockedGroupName) { throw new Exception(); return(false); }