/// <summary> /// Gets the specified rules. /// </summary> /// <param name="rulesId">The rules identifier.</param> /// <returns>The rules requested.</returns> public static Entites.Rules Get(int rulesId) { using (TerministratorContext context = new TerministratorContext(true)) { return(context.Rules.Find(rulesId)); } }
/// <summary> /// Counts how many message types there are. /// </summary> /// <returns>The amount of message types.</returns> public static int Count() { using (TerministratorContext context = new TerministratorContext(true)) { return(context.MessageType.Count()); } }
/// <summary> /// Gets the specified privileges. /// </summary> /// <param name="privilegesId">The privileges identifier.</param> /// <returns>The requested privileges.</returns> public static Entites.Privileges Get(int privilegesId) { using (TerministratorContext context = new TerministratorContext(true)) { return(context.Privileges.Find(privilegesId)); } }
/// <summary> /// Deletes all message types from the database. /// </summary> public static void DeleteAll() { using (TerministratorContext context = new TerministratorContext(true)) { context.MessageType.RemoveRange(context.MessageType); } }
/// <summary> /// Gets the specified text. /// </summary> /// <param name="messageContentId">The text identifier.</param> /// <returns>The text with the specified identifier.</returns> public static Entites.Text Get(int messageContentId) { using (TerministratorContext context = new TerministratorContext(true)) { return(context.Text.Find(messageContentId)); } }
/// <summary> /// Counts the number of messages a user sent in a channel. /// </summary> /// <param name="userToChannelId">The user to channel identifier.</param> /// <returns>The number of messages a user sent in a channel</returns> public static int CountMessage(int userToChannelId) { using (TerministratorContext context = new TerministratorContext(true)) { Entites.UserToChannel userToChannel = context.UserToChannel.Find(userToChannelId); return(userToChannel == null ? 0 : LoadMessage(userToChannel).Messages.Count); } }
/// <summary> /// Gets all message types. /// </summary> /// <returns>The collection of message types.</returns> public static List <Entites.MessageType> GetAll() { using (TerministratorContext context = new TerministratorContext(true)) { return((from c in context.MessageType select c).ToList()); } }
/// <summary> /// Gets the specified blocked word. /// </summary> /// <param name="word">The word.</param> /// <returns>The requested blocked word.</returns> public static Entites.BlockedWord Get(string word) { using (TerministratorContext context = new TerministratorContext(true)) { return((from c in context.BlockedWord where c.Word == word select c).FirstOrDefault()); } }
/// <summary> /// Loads the text collection of a message. /// </summary> /// <param name="message">The message.</param> /// <returns>The same message with the text collection loaded.</returns> public static Entites.Message LoadTexts(Entites.Message message) { using (TerministratorContext context = new TerministratorContext(true)) { context.Message.Attach(message); context.Entry(message).Collection(p => p.Texts).Load(); } return(message); }
/// <summary> /// Loads the user reference. /// </summary> /// <param name="userToChannel">The user to channel.</param> /// <returns>The user to channel with the initialized user reference.</returns> public static Entites.UserToChannel LoadUser(Entites.UserToChannel userToChannel) { using (TerministratorContext context = new TerministratorContext(true)) { context.UserToChannel.Attach(userToChannel); context.Entry(userToChannel).Reference(p => p.User).Load(); } return(userToChannel); }
/// <summary> /// Loads the point system. /// </summary> /// <param name="channel">The channel.</param> /// <returns>The same channel with the point system reference loaded.</returns> public static Entites.Channel LoadPointSystem(Entites.Channel channel) { using (TerministratorContext context = new TerministratorContext(true)) { context.Channel.Attach(channel); context.Entry(channel).Reference(p => p.PointSystem).Load(); } return(channel); }
/// <summary> /// Loads the user names. /// </summary> /// <param name="channel">The channel.</param> /// <returns>The same channel with the user names collection loaded.</returns> public static Entites.Channel LoadUserNames(Entites.Channel channel) { using (TerministratorContext context = new TerministratorContext(true)) { context.Channel.Attach(channel); context.Entry(channel).Collection(p => p.UserNames).Load(); } return(channel); }
/// <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); } }
/// <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); } }
/// <summary> /// Loads the channels collection of the user. /// </summary> /// <param name="user">The user.</param> /// <returns>The same user with an initialized channel collection.</returns> public static Entites.User LoadChannels(Entites.User user) { using (TerministratorContext context = new TerministratorContext(true)) { context.User.Attach(user); context.Entry(user).Collection(p => p.Channels).Load(); } return(user); }
/// <summary> /// Loads the similar texts reference. /// </summary> /// <param name="text">The text.</param> /// <returns>The same text with the reference updated.</returns> public static Entites.Text LoadSimilarTexts(Entites.Text text) { using (TerministratorContext context = new TerministratorContext(true)) { context.Text.Attach(text); context.Entry(text).Reference(p => p.SimilarContent).Load(); } return(text); }
/// <summary> /// Gets the specified ad system associated to a channel. /// </summary> /// <param name="channelId">The channel identifier (Namable).</param> /// <returns>The requested ad system.</returns> public static Entites.AdSystem Get(int channelId) { using (TerministratorContext context = new TerministratorContext(true)) { return((from c in context.AdSystem where c.ChannelId == channelId select c).FirstOrDefault()); } }
/// <summary> /// Gets the specified message type. /// </summary> /// <param name="name">The name of the requested message type.</param> /// <returns>The requested message type.</returns> public static Entites.MessageType Get(string name) { using (TerministratorContext context = new TerministratorContext(true)) { return((from c in context.MessageType where c.Name == name select c).FirstOrDefault()); } }
/// <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(); } }
/// <summary> /// Gets all the channels in a given application. /// </summary> /// <param name="application">The application.</param> /// <returns>The requested channel.</returns> public static List <Entites.Channel> Get(string application) { using (TerministratorContext context = new TerministratorContext(true)) { return((from c in context.Channel where c.Application.ApplicationName == application select c).Include(x => x.UserNames).ToList()); } }
/// <summary> /// Loads the ad system associated to the ad. /// </summary> /// <param name="ad">The ad.</param> /// <returns>The same ad with the ad system reference loaded.</returns> public static Entites.Ad LoadAdSystem(Entites.Ad ad) { using (TerministratorContext context = new TerministratorContext(true)) { context.Ad.Attach(ad); context.Entry(ad).Reference(p => p.AdSystem).Load(); } return(ad); }
/// <summary> /// Loads the application of the message. /// </summary> /// <param name="message">The message.</param> /// <returns>The same message with the application instance initialized.</returns> public static Entites.Message LoadApplication(Entites.Message message) { using (TerministratorContext context = new TerministratorContext(true)) { context.Message.Attach(message); context.Entry(message).Reference(p => p.Application).Load(); } return(message); }
/// <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); } }
/// <summary> /// Gets the specified application name. /// </summary> /// <param name="applicationName">Name of the application.</param> /// <returns>The requested application.</returns> public static Entites.Application Get(string applicationName) { using (TerministratorContext context = new TerministratorContext(true)) { return((from c in context.Application where c.ApplicationName == applicationName select c).FirstOrDefault()); } }
/// <summary> /// Loads the message collection. /// </summary> /// <param name="userToChannel">The user to channel.</param> /// <returns>The user to channel with the initialized message collection.</returns> public static Entites.UserToChannel LoadMessage(Entites.UserToChannel userToChannel) { using (TerministratorContext context = new TerministratorContext(true)) { userToChannel.Messages = (from c in context.Message where c.UserToChannelId == userToChannel.UserToChannelId select c).ToList(); } return(userToChannel); }
/// <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 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)); }
/// <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)); }
/// <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)); }
/// <summary> /// For an applicationReferencableId and the application's id, find all the user names associated to a user. /// </summary> /// <param name="userId">The user identifier.</param> /// <param name="application">The application.</param> /// <returns></returns> public static List <Entites.UserName> GetAll(string userId, string application) { using (TerministratorContext context = new TerministratorContext(true)) { return((from c in context.UserName where c.OwnedBy.IdForApplication == userId && c.OwnedBy.Application.ApplicationName == application select c).ToList()); } }