本文整理汇总了C#中RDN.Library.DataModels.Context.ManagementContext.Entry方法的典型用法代码示例。如果您正苦于以下问题:C# ManagementContext.Entry方法的具体用法?C# ManagementContext.Entry怎么用?C# ManagementContext.Entry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RDN.Library.DataModels.Context.ManagementContext
的用法示例。
在下文中一共展示了ManagementContext.Entry方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReplyToPost
public static void ReplyToPost(Guid forumId, long topicId, string message, Guid memberId, bool emailGroupAboutPost)
{
try
{
var dc = new ManagementContext();
var topic = dc.ForumTopics.Where(x => x.Forum.ForumId == forumId).Where(x => x.TopicId == topicId).FirstOrDefault();
if (topic != null)
{
var member = dc.Members.Where(x => x.MemberId == memberId).FirstOrDefault();
member.TotalForumPosts = member.TotalForumPosts + 1;
DataModels.Forum.ForumMessage mess = new DataModels.Forum.ForumMessage();
mess.Member = member;
if (!String.IsNullOrEmpty(message))
{
message = message.Replace(Environment.NewLine, "<br/>");
message = message.Replace("\r", "<br/>");
}
mess.MessageHTML = message;
if (!String.IsNullOrEmpty(message))
mess.MessagePlain = _htmlRegex.Replace(message, " ");
mess.Topic = topic;
topic.Forum = topic.Forum;
mess.LastModified = DateTime.UtcNow;
topic.LastModified = DateTime.UtcNow;
dc.Entry(topic).Reference(c => c.LastPostByMember).Load();
topic.LastPostByMember = member;
topic.LastPostDateTime = DateTime.UtcNow;
topic.CreatedByMember = topic.CreatedByMember;
dc.ForumMessages.Add(mess);
int ch = dc.SaveChanges();
UpdateForumInbox(dc, topic, memberId);
string groupName = "Forum";
if (topic.Forum.LeagueOwner != null)
groupName = topic.Forum.LeagueOwner.Name;
if (topic.GroupId > 0)
{
try
{
var group = SiteCache.GetAllGroups().Where(x => x != null && x.Id == topic.GroupId).FirstOrDefault();
if (group != null)
groupName = group.GroupName;
}
catch (Exception exception)
{
ErrorDatabaseManager.AddException(exception, exception.GetType(), additionalInformation: forumId + ":" + topicId + ":" + message + ":" + memberId + ":" + emailGroupAboutPost + ":" + topic.GroupId);
}
}
Guid ownerId = new Guid();
if (topic.Forum.LeagueOwner != null)
ownerId = topic.Forum.LeagueOwner.LeagueId;
var notify = new ForumNotificationFactory(forumId, ownerId, false, emailGroupAboutPost, topic.GroupId, topic.TopicId, groupName, topic.TopicTitle, message, member.MemberId, member.DerbyName)
.LeagueEmailAboutForumPost()
.EmailMembersOnWatchList();
var fact = new MobileNotificationFactory()
.Initialize("Forum Reply:", topic.TopicTitle, Mobile.Enums.NotificationTypeEnum.Forum)
.AddId(topic.TopicId)
.AddMembers(notify.membersAlreadyEmailed)
.SendNotifications();
}
}
catch (Exception exception)
{
ErrorDatabaseManager.AddException(exception, exception.GetType(), additionalInformation: forumId + ":" + topicId + ":" + message + ":" + memberId + ":" + emailGroupAboutPost);
}
}
示例2: MoveFolderToAnotherFolder
public static bool MoveFolderToAnotherFolder(Guid ownerId, long folderId, long parentFolderId)
{
try
{
var dc = new ManagementContext();
var docs = dc.LeagueDocumentFolders.Where(x => x.League.LeagueId == ownerId && x.CategoryId == folderId).FirstOrDefault();
bool isMem = MemberCache.IsMemberApartOfLeague(RDN.Library.Classes.Account.User.GetMemberId(), docs.League.LeagueId);
if (isMem)
{
if (docs != null)
{
if (parentFolderId == 0 || parentFolderId == folderId)
{
dc.Entry(docs).Reference(x => x.ParentFolder).CurrentValue = null;
dc.Entry(docs).Reference(x => x.Group).CurrentValue = null;
}
else
docs.ParentFolder = dc.LeagueDocumentFolders.Where(x => x.CategoryId == parentFolderId).FirstOrDefault();
int c = dc.SaveChanges();
return c > 0;
}
}
}
catch (Exception exception)
{
ErrorDatabaseManager.AddException(exception, exception.GetType());
}
return false;
}
示例3: UpdateTopicCategoryAndGroup
public static bool UpdateTopicCategoryAndGroup(Guid forumId, long topicId, long groupId, long categoryId)
{
try
{
var dc = new ManagementContext();
var topic = dc.ForumTopics.Include("Category").Where(x => x.Forum.ForumId == forumId && x.TopicId == topicId).FirstOrDefault();
topic.LastPostByMember = topic.LastPostByMember;
if (topic.CreatedByMember != null)
topic.CreatedByMember = topic.CreatedByMember;
else
topic.CreatedByMember = topic.LastPostByMember;
topic.Forum = topic.Forum;
topic.GroupId = groupId;
if (categoryId == 0)
{
dc.Entry(topic).Reference(x => x.Category).CurrentValue = null;
}
else
{
topic.Category = dc.ForumCetegories.Where(x => x.CategoryId == categoryId && x.Forum.ForumId == forumId).FirstOrDefault();
topic.Category.CreatedByMember = topic.Category.CreatedByMember;
topic.Category.Forum = topic.Category.Forum;
dc.Entry(topic.Category).State = System.Data.Entity.EntityState.Modified;
}
int c = dc.SaveChanges();
return c > 0;
}
catch (Exception exception)
{
ErrorDatabaseManager.AddException(exception, exception.GetType());
}
return false;
}
示例4: MoveDocumentToGroup
public static bool MoveDocumentToGroup(Guid ownerId, long groupId, long docId)
{
try
{
Document doc = new Document();
var dc = new ManagementContext();
var docs = dc.LeagueDocuments.Where(x => x.League.LeagueId == ownerId && x.DocumentId == docId).FirstOrDefault();
bool isMem = MemberCache.IsMemberApartOfLeague(RDN.Library.Classes.Account.User.GetMemberId(), docs.League.LeagueId);
if (isMem)
{
if (docs != null)
{
docs.Document = docs.Document;
docs.Group = dc.LeagueGroups.Where(x => x.Id == groupId).FirstOrDefault();
dc.Entry(docs).Reference(x => x.Category).CurrentValue = null;
int c = dc.SaveChanges();
return c > 0;
}
}
}
catch (Exception exception)
{
ErrorDatabaseManager.AddException(exception, exception.GetType());
}
return false;
}