/// <summary>
 /// Deletes all the message type to point systems from the point system.
 /// </summary>
 /// <param name="pointSystemId">The point system identifier.</param>
 public static void DeleteAllFrom(int pointSystemId)
 {
     using (TerministratorContext context = new TerministratorContext(true))
     {
         context.MessageTypeToPointSystem.RemoveRange(
             context.MessageTypeToPointSystem.Where(x => x.PointSystemId == pointSystemId));
         context.SaveChanges();
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Creates the specified message type.
 /// </summary>
 /// <param name="messageType">Type of the message.</param>
 /// <returns>The same message type with an updated ID.</returns>
 public static Entites.MessageType Create(Entites.MessageType messageType)
 {
     using (TerministratorContext context = new TerministratorContext(true))
     {
         messageType.MessageTypeId = context.MessageType.Add(messageType).MessageTypeId;
         context.SaveChanges();
         return(messageType);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Creates the specified blocked word.
 /// </summary>
 /// <param name="blockedWord">The blocked word.</param>
 /// <returns>The same blocked word with an updated ID.</returns>
 public static Entites.BlockedWord Create(Entites.BlockedWord blockedWord)
 {
     using (TerministratorContext context = new TerministratorContext(true))
     {
         blockedWord.BlockedWordId = context.BlockedWord.Add(blockedWord).BlockedWordId;
         context.SaveChanges();
         return(blockedWord);
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Creates the specified application.
 /// </summary>
 /// <param name="application">The application.</param>
 /// <returns>The same application with an updated ID.</returns>
 public static Entites.Application Create(Entites.Application application)
 {
     using (TerministratorContext context = new TerministratorContext(true))
     {
         application = context.Application.Add(application);
         context.SaveChanges();
         return(application);
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// Creates the specified user.
 /// </summary>
 /// <param name="user">The user.</param>
 /// <returns>The same user with an updated id.</returns>
 public static Entites.User Create(Entites.User user)
 {
     Entites.User reference = ClearReferences(user);
     using (TerministratorContext context = new TerministratorContext(true))
     {
         user.NamableId = context.User.Add(user).NamableId;
         context.SaveChanges();
     }
     return(AddReferences(user, reference));
 }
Exemplo n.º 6
0
 /// <summary>
 /// Creates the specified text.
 /// </summary>
 /// <param name="text">The text.</param>
 /// <returns>The same text with an updated id.</returns>
 public static Entites.Text Create(Entites.Text text)
 {
     Entites.Text reference = ClearReferences(text);
     using (TerministratorContext context = new TerministratorContext(true))
     {
         text.MessageContentId = context.Text.Add(text).MessageContentId;
         context.SaveChanges();
     }
     return(AddReferences(text, reference));
 }
Exemplo n.º 7
0
 /// <summary>
 /// Creates the specified message.
 /// </summary>
 /// <param name="message">The message.</param>
 /// <returns>The same message with an updated ID.</returns>
 public static Entites.Message Create(Entites.Message message)
 {
     Entites.Message reference = ClearReferences(message);
     using (TerministratorContext context = new TerministratorContext(true))
     {
         message.MessageId = context.Message.Add(message).MessageId;
         context.SaveChanges();
     }
     return(AddReferences(message, reference));
 }
Exemplo n.º 8
0
 /// <summary>
 /// Creates the specified user to channel in the database.
 /// </summary>
 /// <param name="userToChannel">The user to channel.</param>
 /// <returns>The user to channel witn an updated ID.</returns>
 public static Entites.UserToChannel Create(Entites.UserToChannel userToChannel)
 {
     Entites.UserToChannel reference = ClearReferences(userToChannel);
     using (TerministratorContext context = new TerministratorContext(true))
     {
         userToChannel.UserToChannelId = context.UserToChannel.Add(userToChannel).UserToChannelId;
         context.SaveChanges();
     }
     return(AddReferences(userToChannel, reference));
 }
Exemplo n.º 9
0
 /// <summary>
 /// Creates the specified ad system.
 /// </summary>
 /// <param name="adSystem">The ad system.</param>
 /// <returns></returns>
 public static Entites.AdSystem Create(Entites.AdSystem adSystem)
 {
     Entites.AdSystem reference = ClearReferences(adSystem);
     using (TerministratorContext context = new TerministratorContext(true))
     {
         context.AdSystem.Add(adSystem);
         context.SaveChanges();
     }
     return(AddReferences(adSystem, reference));
 }
Exemplo n.º 10
0
 /// <summary>
 /// Creates the specified rules.
 /// </summary>
 /// <param name="rules">The rules.</param>
 /// <returns>The same rules with the updated ID.</returns>
 public static Entites.Rules Create(Entites.Rules rules)
 {
     Entites.Rules reference = ClearReferences(rules);
     using (TerministratorContext context = new TerministratorContext(true))
     {
         rules.RulesId = context.Rules.Add(rules).RulesId;
         context.SaveChanges();
     }
     return(AddReferences(rules, reference));
 }
Exemplo n.º 11
0
 /// <summary>
 /// Creates the specified user name.
 /// </summary>
 /// <param name="userName">The user name.</param>
 /// <returns>The same user name with the id updated.</returns>
 public static Entites.UserName Create(Entites.UserName userName)
 {
     Entites.UserName reference = ClearReferences(userName);
     using (TerministratorContext context = new TerministratorContext(true))
     {
         userName.UserNameId = context.UserName.Add(userName).UserNameId;
         context.SaveChanges();
     }
     return(AddReferences(userName, reference));
 }
Exemplo n.º 12
0
 /// <summary>
 /// Creates the specified ad.
 /// </summary>
 /// <param name="ad">The ad.</param>
 /// <returns>The same ad with an updated ID.</returns>
 public static Entites.Ad Create(Entites.Ad ad)
 {
     Entites.Ad reference = ClearReferences(ad);
     using (TerministratorContext context = new TerministratorContext(true))
     {
         ad.AdId = context.Ad.Add(ad).AdId;
         context.SaveChanges();
     }
     return(AddReferences(ad, reference));
 }
 /// <summary>
 /// Creates the specified message type to point system.
 /// </summary>
 /// <param name="messageTypeToPointSystem">The message type to point system.</param>
 /// <returns>The same message type to point system.</returns>
 public static Entites.MessageTypeToPointSystem Create(Entites.MessageTypeToPointSystem messageTypeToPointSystem)
 {
     Entites.MessageTypeToPointSystem reference = ClearReferences(messageTypeToPointSystem);
     using (TerministratorContext context = new TerministratorContext(true))
     {
         context.MessageTypeToPointSystem.Add(messageTypeToPointSystem);
         context.SaveChanges();
     }
     return(AddReferences(messageTypeToPointSystem, reference));
 }
Exemplo n.º 14
0
 /// <summary>
 /// Creates the specified channel.
 /// </summary>
 /// <param name="channel">The channel.</param>
 /// <returns>The same channel with the updated ID.</returns>
 public static Entites.Channel Create(Entites.Channel channel)
 {
     Entites.Channel reference = ClearReferences(channel);
     using (TerministratorContext context = new TerministratorContext(true))
     {
         Entites.Channel newChannel = context.Channel.Add(channel);
         channel.NamableId = newChannel.NamableId;
         context.SaveChanges();
     }
     return(AddReferences(channel, reference));
 }
Exemplo n.º 15
0
 /// <summary>
 /// Switch the user name to a non-current state.
 /// </summary>
 /// <param name="ownedById">The user identifier.</param>
 public static void UpdateUserName(int ownedById)
 {
     using (TerministratorContext context = new TerministratorContext(true))
     {
         (from c in context.UserName
          where c.OwnedById == ownedById &&
          c.Current
          select c).First().Current = false;
         context.SaveChanges();
     }
 }
Exemplo n.º 16
0
 /// <summary>
 /// Updates the blocked words.
 /// </summary>
 /// <param name="rules">The rules.</param>
 /// <returns></returns>
 public static Entites.Rules UpdateBlockedWords(Entites.Rules rules)
 {
     using (TerministratorContext context = new TerministratorContext(true))
     {
         Entites.Rules old = context.Rules.Find(rules.RulesId);
         if (old != null)
         {
             old.BlockedWords = rules.BlockedWords;
             context.SaveChanges();
         }
     }
     return(rules);
 }
Exemplo n.º 17
0
 /// <summary>
 /// Updates the name of the specified message type.
 /// </summary>
 /// <param name="messageType">Type of the message.</param>
 /// <returns>The same message type.</returns>
 public static Entites.MessageType Update(Entites.MessageType messageType)
 {
     using (TerministratorContext context = new TerministratorContext(true))
     {
         Entites.MessageType original = context.MessageType.Find(messageType.MessageTypeId);
         if (original != null)
         {
             original.Name = messageType.Name;
             context.SaveChanges();
         }
         return(original);
     }
 }
Exemplo n.º 18
0
 /// <summary>
 /// Updates the specified ad system.
 /// </summary>
 /// <param name="adSystem">The ad system.</param>
 /// <returns>The same ad system.</returns>
 public static Entites.AdSystem Update(Entites.AdSystem adSystem)
 {
     using (TerministratorContext context = new TerministratorContext(true))
     {
         Entites.AdSystem original = context.AdSystem.Find(adSystem.ChannelId);
         if (original != null)
         {
             original.BothConditions = adSystem.BothConditions;
             original.MinNbOfMessage = adSystem.MinNbOfMessage;
             original.MinTime        = adSystem.MinTime;
             context.SaveChanges();
         }
         return(original);
     }
 }
Exemplo n.º 19
0
 /// <summary>
 /// Updates the specified application.
 /// </summary>
 /// <param name="application">The application.</param>
 /// <returns>The same application</returns>
 public static Entites.Application Update(Entites.Application application)
 {
     using (TerministratorContext context = new TerministratorContext(true))
     {
         Entites.Application original = context.Application.Find(application.ApplicationName);
         if (original != null)
         {
             original.CommandSymbols = application.CommandSymbols;
             original.UserSymbols    = application.UserSymbols;
             original.Token          = original.Token;
             context.SaveChanges();
         }
     }
     return(application);
 }
Exemplo n.º 20
0
 /// <summary>
 /// Updates the specified text.
 /// </summary>
 /// <param name="text">The text.</param>
 /// <returns>The same text given in arguement.</returns>
 public static Entites.Text Update(Entites.Text text)
 {
     using (TerministratorContext context = new TerministratorContext(true))
     {
         Entites.Text old = context.Text.Find(text.MessageContentId);
         if (old != null)
         {
             old.SimilarContentId = text.SimilarContentId;
             context.SaveChanges();
             context.Entry(old).Reference(x => x.SimilarContent);
         }
         text.SimilarContent = old?.SimilarContent;
     }
     return(text);
 }
Exemplo n.º 21
0
 /// <summary>
 /// Updates the specified privileges.
 /// </summary>
 /// <param name="privileges">The privileges.</param>
 /// <returns>The same privileges.</returns>
 public static Entites.Privileges Update(Entites.Privileges privileges)
 {
     using (TerministratorContext context = new TerministratorContext(true))
     {
         Entites.Privileges old = context.Privileges.Find(privileges.PrivilegesId);
         if (old != null)
         {
             old.Name    = privileges.Name;
             old.RulesId = privileges.RulesId;
             old.Default = privileges.Default;
             context.SaveChanges();
         }
     }
     return(privileges);
 }
Exemplo n.º 22
0
 /// <summary>
 /// Updates the specified ad.
 /// </summary>
 /// <param name="ad">The ad.</param>
 /// <returns>The same ad.</returns>
 public static Entites.Ad Update(Entites.Ad ad)
 {
     using (TerministratorContext context = new TerministratorContext(true))
     {
         Entites.Ad old = context.Ad.Find(ad.AdId);
         if (old != null)
         {
             old.MaxShow  = ad.MaxShow;
             old.Name     = ad.Name;
             old.LastSent = ad.LastSent;
             context.SaveChanges();
         }
     }
     return(ad);
 }
Exemplo n.º 23
0
 /// <summary>
 /// Updates the specified user to channel in the database.
 /// </summary>
 /// <param name="userToChannel">The user to channel.</param>
 /// <returns>The same user to channel that was given in entry.</returns>
 public static Entites.UserToChannel Update(Entites.UserToChannel userToChannel)
 {
     using (TerministratorContext context = new TerministratorContext(true))
     {
         Entites.UserToChannel original = context.UserToChannel.Find(userToChannel.UserToChannelId);
         if (original != null)
         {
             original.Points       = userToChannel.Points;
             original.PrivilegesId = userToChannel.PrivilegesId;
             original.NbSilences   = userToChannel.NbSilences;
             original.SilencedTo   = userToChannel.SilencedTo;
             context.SaveChanges();
         }
     }
     return(userToChannel);
 }
Exemplo n.º 24
0
 /// <summary>
 /// Updates the specified rules.
 /// </summary>
 /// <param name="rules">The rules.</param>
 /// <returns>The same rules.</returns>
 public static Entites.Rules Update(Entites.Rules rules)
 {
     using (TerministratorContext context = new TerministratorContext(true))
     {
         Entites.Rules old = context.Rules.Find(rules.RulesId);
         if (old != null)
         {
             old.SpamDelay           = rules.SpamDelay;
             old.BlockedWordsEnabled = rules.BlockedWordsEnabled;
             old.DomainBlocked       = rules.DomainBlocked;
             old.ExtensionBlocked    = rules.ExtensionBlocked;
             old.MessageTypeBlocked  = rules.MessageTypeBlocked;
             old.R9KEnabled          = rules.R9KEnabled;
             context.SaveChanges();
         }
     }
     return(rules);
 }