Ejemplo n.º 1
0
 /// <summary>
 /// Creates a rules object with a maximum amount of rules.
 /// </summary>
 /// <returns>The requested rules</returns>
 public static Entites.Rules GetNewUserRules()
 {
     Entites.Rules rules = new Entites.Rules(TimeSpan.FromSeconds(10), true, true, true, true, true)
     {
         BlockedWords = BlockedWord.GetDefaultBlockedWords()
     };
     return(rules);
 }
Ejemplo n.º 2
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));
 }
Ejemplo n.º 3
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);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Loads the blocked extensions associated to rules.
 /// </summary>
 /// <param name="rules">The rules.</param>
 /// <returns>The same rules with the blocked extensions collection initialized.</returns>
 public static Entites.Rules LoadExtensions(Entites.Rules rules)
 {
     using (TerministratorContext context = new TerministratorContext(true))
     {
         if (rules.Extensions != null)
         {
             rules.Extensions = null;
         }
         if (context.Entry(rules).State == EntityState.Detached)
         {
             context.Rules.Attach(rules);
         }
         context.Entry(rules).Collection(p => p.Extensions).Load();
     }
     return(rules);
 }
Ejemplo n.º 5
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);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Adds the references of the second arguement in the first one.
 /// </summary>
 /// <param name="rules">The rules to add the references in.</param>
 /// <param name="reference">The references.</param>
 /// <returns>The first arguement.</returns>
 private static Entites.Rules AddReferences(Entites.Rules rules, Entites.Rules reference)
 {
     return(rules);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Clears the references of the rules.
 /// </summary>
 /// <param name="rules">The rules.</param>
 /// <returns>A copy of the rules given in entry with only the references.</returns>
 private static Entites.Rules ClearReferences(Entites.Rules rules)
 {
     return(null);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Creates the specified rules.
 /// </summary>
 /// <param name="rules">The rules.</param>
 /// <returns>The same rules with an updated ID.</returns>
 public static Entites.Rules Create(Entites.Rules rules)
 {
     return(DAL.Rules.Create(rules));
 }