/// <summary> /// Gets the point system linked to the specified channel. /// </summary> /// <param name="channelId">The channel identifier.</param> /// <returns>The point system requested.</returns> public static Entites.PointSystem Get(int channelId) { using (TerministratorContext context = new TerministratorContext(true)) { return(context.PointSystem.Find(channelId)); } }
/// <summary> /// Gets the specified similar texts. /// </summary> /// <param name="similarTextsId">The similar texts identifier.</param> /// <returns>The specified similar texts</returns> public static Entites.SimilarContent Get(int similarTextsId) { using (TerministratorContext context = new TerministratorContext(true)) { return(context.SimilarTexts.Find(similarTextsId)); } }
/// <summary> /// Refreshes the pings in the console. /// </summary> /// <param name="obj">Unused.</param> private void RefreshPings(object obj) { _mainConsole.RefreshPing(0, TerministratorContext.Ping()?.Milliseconds); for (var i = 0; i < _applications.Count; i++) { _mainConsole.RefreshPing(i + 1, _applications[i].Ping()?.Milliseconds); } }
/// <summary> /// Creates the specified similar text. /// </summary> /// <param name="similarContent">The similar text.</param> /// <returns>The similar text with an updated ID.</returns> public static Entites.SimilarContent Create(Entites.SimilarContent similarContent) { using (TerministratorContext context = new TerministratorContext(true)) { similarContent.SimilarMessagesId = context.SimilarTexts.Add(similarContent).SimilarMessagesId; context.SaveChanges(); } return(similarContent); }
/// <summary> /// Creates the specified point system. /// </summary> /// <param name="pointSystem">The point system.</param> /// <returns>The same point system with an updated ID.</returns> public static Entites.PointSystem Create(Entites.PointSystem pointSystem) { Entites.PointSystem reference = ClearReferences(pointSystem); using (TerministratorContext context = new TerministratorContext(true)) { context.PointSystem.Add(pointSystem); context.SaveChanges(); } return(AddReferences(pointSystem, reference)); }
/// <summary> /// Loads the message type collection of the point system.. /// </summary> /// <param name="pointSystem">The point system.</param> /// <returns>The same point system with an initialized message type to point system collection.</returns> public static Entites.PointSystem LoadMessageTypes(Entites.PointSystem pointSystem) { if (pointSystem == null) { return(null); } using (TerministratorContext context = new TerministratorContext(true)) { context.PointSystem.Attach(pointSystem); context.Entry(pointSystem).Collection(p => p.MessageTypeToPointSystem).Load(); } return(pointSystem); }
/// <summary> /// Updates the specified similar text. /// </summary> /// <param name="similarContent">The similar text.</param> /// <returns>The same similar text.</returns> public static Entites.SimilarContent Update(Entites.SimilarContent similarContent) { using (TerministratorContext context = new TerministratorContext(true)) { Entites.SimilarContent old = context.SimilarTexts.Find(similarContent.SimilarMessagesId); if (old != null) { old.LastIncrement = similarContent.LastIncrement; old.NBSimilar = similarContent.NBSimilar; context.SaveChanges(); } } return(similarContent); }