public virtual void Upsert(Notification notification, List<NotificationMeta> notifyMetas, List<Guid> userIDs, out Exception exception) { SqlParameter categoryIDParam = new SqlParameter("@CategoryID", notification.CategoryID); SqlParameter topicIDParam = new SqlParameter("@TopicID", notification.TopicID); SqlParameter notifyTextParam = new SqlParameter("@NotifyText", notification.NotifyText); SqlParameter tagParam = new SqlParameter("@Tag", notification.Tag); SqlParameter variantParam = new SqlParameter("@Variant", notification.Variant); SqlParameter cultureParam = new SqlParameter("@Culture", notification.Culture); SqlParameter notifyMetasParam = NotificationsTVP.ToNotificationMetaType("@NotifyMetas", notifyMetas, _prefix); SqlParameter userIDParam = CoreTVP.ToGuidType("@UserIDs", userIDs, _prefix); _сrud.DbSafeCallAndDispose((context) => { string command = string.Format("EXEC {0}Notifications_Upsert @CategoryID, @TopicID, @NotifyText, @Tag, @Variant, @Culture, @NotifyMetas, @UserIDs", _prefix); context.Database.ExecuteSqlCommand(command, categoryIDParam, topicIDParam, notifyTextParam , tagParam, variantParam, cultureParam, notifyMetasParam, userIDParam); } , out exception); if (_logger != null && exception != null) { _logger.Exception(exception); } }
public void Insert(Notification notify, List<Guid> receivers, out Exception exception , List<NotificationMeta> metaStrings = null) { exception = null; if (receivers.Count == 0) return; NotificationSettings settings = _settings.FindNotificationSettings(notify.CategoryID); if (metaStrings == null || !settings.SaveMeta) metaStrings = new List<NotificationMeta>(); //добавление в базу if (settings.UpsertSameTopic) { _settings.NotificationQueries.Upsert(notify, metaStrings, receivers, out exception); } else { _settings.NotificationQueries.Insert(notify, metaStrings, receivers, out exception); } }
//добавление public void Insert(Notification notify, Guid receiver, out Exception exception , List<NotificationMeta> metaStrings = null) { Insert(notify, new List<Guid> { receiver }, out exception, metaStrings); }