コード例 #1
0
        /// <summary>
        /// 新增/修改 通知对象
        /// </summary>
        /// <param name="subscription"></param>
        /// <returns></returns>
        public async Task <AjaxResponse> SaveNotificationInfoAsync(SysNotificationInfoInput modelInput)
        {
            SysNotificationInfo notificationInfo = ObjectMapper.Map <SysNotificationInfo>(modelInput);
            //验证通知类型名称(NotificationName)是否重复
            var res = await _sysNotificationInfoRepository.IsSubscriptionRepeat(notificationInfo);

            if (res)
            {
                throw new UserFriendlyException("通知类型名称重复", "您设置的通知类型名称:" + modelInput.NotificationName + "重复");
            }
            if (modelInput.Id == null)
            {
                //新增时默认设置所有所有用户订阅该通知
                await _sysNotificationInfoRepository.AddAllUserSubscriptionAsync(notificationInfo);
            }
            else
            {
                //编辑状态设置编辑后的通知类型名称
                notificationInfo = await _sysNotificationInfoRepository.UpdateAllUserSubscriptionAsync(notificationInfo);

                //清楚该订阅的缓存
                _cacheManagerExtens.RemoveNotificationCache(notificationInfo.NotificationName);
            }
            //
            var gid = await _sysNotificationInfoRepository.InsertOrUpdateAndGetIdAsync(notificationInfo);

            return(new AjaxResponse {
                Success = true, Result = gid
            });
        }
コード例 #2
0
 /// <summary>
 /// 删除通知对象
 /// </summary>
 /// <param name="modelInput"></param>
 /// <returns></returns>
 public async Task DelNotificationInfoAsync(SysNotificationInfoInput modelInput)
 {
     SysNotificationInfo notificationInfo = ObjectMapper.Map <SysNotificationInfo>(modelInput);
     await _sysNotificationInfoRepository.DeleteNotificationAndSubscriptionAsync(notificationInfo);
 }