/// <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 }); }
/// <summary> /// 新增/修改 通知对象 /// </summary> /// <param name="subscription"></param> /// <returns></returns> public async Task <AjaxResponse> SaveNotificationInfoAsync(SysNotificationInfoInput modelInput) { SysNotificationInfo notificationInfo = modelInput.MapTo <SysNotificationInfo>(); //验证通知类型名称(NotificationName)是否重复 var res = await _sysNotificationInfoRepository.IsSubscriptionRepeat(notificationInfo); if (res) { //throw new UserFriendlyException(L("IsRepeat", modelInput.NotificationName)); return(new AjaxResponse { Success = false, Error = new ErrorInfo(L("IsRepeat", 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 }); }