/// <summary> /// 转换为实体 /// </summary> /// <param name="invitationSettings"></param> /// <returns></returns> public NoticeSettings AsMessagesSettings(out InvitationSettings invitationSettings) { NoticeSettings noticeSettings = new NoticeSettings(); noticeSettings.NoticeTypeSettingses = NoticeTypeSettings; invitationSettings = new InvitationSettings(); invitationSettings.InvitationTypeSettingses = InvitationTypeSettings; return noticeSettings; }
/// <summary> /// 构造函数 /// </summary> /// <param name="noticeSettings"></param> /// <param name="invitationSettings"></param> public MessagesSettingEditModel(NoticeSettings noticeSettings, InvitationSettings invitationSettings) { if (noticeSettings != null) { NoticeTypeSettings = noticeSettings.NoticeTypeSettingses; } if (invitationSettings!=null) { InvitationTypeSettings = invitationSettings.InvitationTypeSettingses; } }
/// <summary> /// 用户对某类型是否允许发送通知 /// </summary> /// <param name="userId">用户Id</param> /// <param name="typeId">通知类型Id</param> /// <returns></returns> public bool IsAllowedSend(long userId, int typeId) { Dictionary <int, bool> userSettings = userNoticeSettingsRepository.GetUserNoticeSettingses(userId); if (userSettings.ContainsKey(typeId)) { return(userSettings[typeId]); } NoticeSettings noticeSettings = noticeSettingsManager.Get(); if (!noticeSettings.NoticeTypeSettingses.Any(n => n.TypeId == typeId)) { return(false); } return(noticeSettings.NoticeTypeSettingses.Single(n => n.TypeId == typeId).IsAllow); }