当前位置: 首页>>代码示例>>C#>>正文


C# ManagementContext.SaveChanges方法代码示例

本文整理汇总了C#中RDN.Library.DataModels.Context.ManagementContext.SaveChanges方法的典型用法代码示例。如果您正苦于以下问题:C# ManagementContext.SaveChanges方法的具体用法?C# ManagementContext.SaveChanges怎么用?C# ManagementContext.SaveChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RDN.Library.DataModels.Context.ManagementContext的用法示例。


在下文中一共展示了ManagementContext.SaveChanges方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddNode

        /// <summary>
        /// Adds a Node to the Site Map
        /// </summary>
        /// <param name="url">URL to add to SiteMap</param>
        /// <param name="modified">true oo false if the item has just been modified.</param>
        public static void AddNode(string url, bool modified)
        {
            var dc = new ManagementContext();
            var site = dc.SiteMap.Where(x => x.Url.ToLower() == url.ToLower()).FirstOrDefault();
            if (site == null)
            {
                Sitemap siteMap = new Sitemap();
                siteMap.ChangeFrequency = Convert.ToInt32(SitemapHelperEnum.monthly);
                siteMap.LastModified = DateTime.UtcNow;
                siteMap.Url = url.ToLower();
                dc.SiteMap.Add(siteMap);
                dc.SaveChanges();
            }
            else
            {
                if (modified)
                {
                    site.LastModified = DateTime.UtcNow;

                    TimeSpan span = DateTime.UtcNow.Subtract(site.LastModified.Value);
                    if (span.Days > 365)
                        site.ChangeFrequency = Convert.ToInt32(SitemapHelperEnum.yearly);
                    else if (span.Days > 31)
                        site.ChangeFrequency = Convert.ToInt32(SitemapHelperEnum.monthly);
                    else if (span.Days > 7)
                        site.ChangeFrequency = Convert.ToInt32(SitemapHelperEnum.weekly);
                    else if (span.Hours > 24)
                        site.ChangeFrequency = Convert.ToInt32(SitemapHelperEnum.daily);
                    else
                        site.ChangeFrequency = Convert.ToInt32(SitemapHelperEnum.hourly);
                    dc.SaveChanges();
                }
            }

        }
开发者ID:mukhtiarlander,项目名称:git_demo_torit,代码行数:40,代码来源:SitemapHelper.cs

示例2: TogglePrivacySettingsForMember

        public static bool TogglePrivacySettingsForMember(Guid memberId, MemberPrivacySettingsEnum privacySetting)
        {
            try
            {
                var dc = new ManagementContext();
                var leagueMember = dc.Members.Include("Settings").Where(x => x.MemberId == memberId).FirstOrDefault();
                if (leagueMember.Settings == null)
                    leagueMember.Settings = new DataModels.Member.MemberSettings();


                MemberPrivacySettingsEnum owner = (MemberPrivacySettingsEnum)leagueMember.Settings.MemberPrivacySettingsEnum;
                bool isType = owner.HasFlag(privacySetting);
                if (isType)
                    owner &= ~privacySetting;
                else
                    owner |= privacySetting;

                leagueMember.Settings.MemberPrivacySettingsEnum = (long)owner;
                int c = dc.SaveChanges();

                return c > 0;
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return false;
        }
开发者ID:mukhtiarlander,项目名称:git_demo_torit,代码行数:28,代码来源:MemberSettings.cs

示例3: MoveOwnersOfGameOverToNewOwnershipSystem

        public static void MoveOwnersOfGameOverToNewOwnershipSystem()
        {
            var dc = new ManagementContext();
            var gameDb = (from xx in dc.Games
                          select xx).ToList();

            foreach (var game in gameDb)
            {
                if (game.OwnerOfGame != null)
                {
                    GameMemberOwnership owner = new GameMemberOwnership();
                    owner.Game = game;
                    owner.Member = game.OwnerOfGame;
                    owner.OwnerType = Convert.ToInt32(GameOwnerEnum.Owner);
                    game.MemberOwners.Add(owner);
                }
                if (game.FederationOwner != null)
                {
                    GameFederationOwnership owner = new GameFederationOwnership();
                    owner.Game = game;
                    owner.Federation = game.FederationOwner;
                    owner.OwnerType = Convert.ToInt32(GameOwnerEnum.Owner);
                    game.FederationOwners.Add(owner);
                }
            }
            dc.SaveChanges();
        }
开发者ID:mukhtiarlander,项目名称:git_demo_torit,代码行数:27,代码来源:GameManager.cs

示例4: AddNewDesignation

        public static bool AddNewDesignation(RDN.Library.Classes.League.Organization designation)
        {

            try
            {
                var dc = new ManagementContext();
                DataModels.League.OrganizationChart.Designation con = new DataModels.League.OrganizationChart.Designation();
                con.DesignationTitle = designation.DesigTitle;
                con.DesignationLevel = designation.DesigLavel;
                con.ShortNote = designation.ShortNote;
                con.League = dc.Leagues.Where(x => x.LeagueId == designation.LeagueId).FirstOrDefault();
                 
                dc.Designations.Add(con);

                int c = dc.SaveChanges();

                return c > 0;

            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());

            }
            return false;
        }
开发者ID:mukhtiarlander,项目名称:git_demo_torit,代码行数:26,代码来源:Organization.cs

示例5: UpdateMerchantSettings

        public bool UpdateMerchantSettings(OverviewMerchant store)
        {
            try
            {
                var dc = new ManagementContext();
                var merc = dc.Merchants.Where(x => x.InternalReference == store.InternalReference && x.MerchantId == store.MerchantId && x.PrivateManagerId == store.PrivateManagerId).FirstOrDefault();

                if (merc != null)
                {
                    merc.OrderPayedNotificationEmail = store.OrderPayedNotificationEmail;
                    merc.PaypalEmail = store.PaypalEmail;
                    //need to make sure we have a paypal email.
                    if (String.IsNullOrEmpty(merc.PaypalEmail))
                        merc.AcceptPaymentsViaPaypal = false;
                    else
                        merc.AcceptPaymentsViaPaypal = store.AcceptPaymentsViaPaypal;
                    if (merc.AcceptPaymentsViaStripe || (store.AcceptPaymentsViaPaypal && !String.IsNullOrEmpty(store.PaypalEmail)))
                        merc.IsPublished = store.IsPublished;
                    else
                        merc.IsPublished = false;

                    dc.SaveChanges();
                    return true;
                }
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return false;
        }
开发者ID:mukhtiarlander,项目名称:git_demo_torit,代码行数:31,代码来源:MerchantGateway.cs

示例6: Add_New_Item

        public static bool Add_New_Item(RDN.Library.Classes.League.ItemInfoDA NewItem)
        {

            try
            {
                var dc = new ManagementContext();
                DataModels.League.ItemInfo con = new DataModels.League.ItemInfo();
                con.ItemSerialNo = NewItem.ItemSerialNo;
                con.ItemName = NewItem.ItemName;
                con.Location = NewItem.Location;
                con.Notes = NewItem.Notes;
                con.Quantity = NewItem.Quantity;
                con.UnitePice = NewItem.UnitePice;

                con.ItemsForLeague = dc.Leagues.Where(x => x.LeagueId == NewItem.ItemsForLeague).FirstOrDefault();
                con.ItemAddByMember = dc.Members.Where(x => x.MemberId == NewItem.ItemAddByMember).FirstOrDefault();
                dc.ItemInfos.Add(con);

                int c = dc.SaveChanges();

                return c > 0;

            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());

            }
            return false;
        }
开发者ID:mukhtiarlander,项目名称:git_demo_torit,代码行数:30,代码来源:ItemInfoDA.cs

示例7: DoUpdates

        public static int DoUpdates()
        {
            try
            {
                int c = 0;
                var dc = new ManagementContext();
                var mems = dc.LeagueMembers.Where(x => x.LeagueOwnersEnum > 0);
                foreach (var mem in mems)
                {
                    mem.LeagueOwnersEnums = (int)mem.LeagueOwnersEnum;
                    if (mem.LeagueOwnersEnum > 0)
                        Console.WriteLine(mem.LeagueOwnersEnum);
                    //leagueMember.LeagueOwnersEnums = (int)owner;
                    mem.League = mem.League;
                    mem.Member = mem.Member;

                }
                c += dc.SaveChanges();


                return c;
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return 0;
        }
开发者ID:mukhtiarlander,项目名称:git_demo_torit,代码行数:28,代码来源:League.cs

示例8: updatePenaltyBoxInDb

 /// <summary>
 /// updates the penalty box DB with new information
 /// </summary>
 /// <param name="game"></param>
 /// <param name="cachedGame"></param>
 /// <param name="db"></param>
 /// <param name="pen"></param>
 public static void updatePenaltyBoxInDb(GameViewModel game, ManagementContext db, SkaterInPenaltyBoxViewModel pen, DataModels.Game.Game g)
 {
     try
     {
         var cachedPen = g.GameMemberPenaltyBox.Where(x => x.PenaltyIdFromGame == pen.PenaltyId).FirstOrDefault();
         if (cachedPen == null)
             insertNewPenaltyIntoDb(game, db, pen, g);
         else
         {
             cachedPen.GameTimeMilliSecondsReturned = pen.GameTimeInMillisecondsReleased;
             cachedPen.GameTimeMilliSecondsSent = pen.GameTimeInMillisecondsSent;
             cachedPen.JamNumberReturned = pen.JamNumberReleased;
             cachedPen.JamNumberSent = pen.JamNumberSent;
             cachedPen.JamIdReturned = pen.JamIdReleased;
             cachedPen.JamIdSent = pen.JamIdSent;
             cachedPen.JamTimeMilliSecondsReturned = pen.JamTimeInMillisecondsReleased;
             cachedPen.JamTimeMilliSecondsSent = pen.JamTimeInMillisecondsSent;
             cachedPen.PenaltyType = pen.PenaltyType.ToString();
             db.SaveChanges();
         }
     }
     catch (Exception exception)
     {
         ErrorDatabaseManager.AddException(exception, exception.GetType());
     }
 }
开发者ID:mukhtiarlander,项目名称:git_demo_torit,代码行数:33,代码来源:GamePenaltiesClass.cs

示例9: AddColor

        public static bool AddColor(string nameOfColor, string colorHex)
        {
            try
            {
                var dc = new ManagementContext();
                Color color = ColorTranslator.FromHtml(colorHex);
                int arb = color.ToArgb();
                var colorDb = dc.Colors.Where(x => x.ColorIdCSharp == arb).FirstOrDefault();

                if (colorDb == null)
                {
                    DataModels.Color.Color co = new DataModels.Color.Color();
                    co.ColorName = nameOfColor;
                    co.ColorIdCSharp = arb;
                    dc.Colors.Add(co);
                    int c = dc.SaveChanges();
                    return c > 0;
                }
                return true;
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType(), additionalInformation: nameOfColor + " " + colorHex);
            }
            return false;
        }
开发者ID:mukhtiarlander,项目名称:git_demo_torit,代码行数:26,代码来源:ColorDisplay.cs

示例10: CommitFeedback

        public static void CommitFeedback(string feedback, string league, string email, FeedbackTypeEnum type)
        {
            try
            {

                ManagementContext db = new ManagementContext();

                ScoreboardFeedback fb = new ScoreboardFeedback();
                fb.Created = DateTime.UtcNow;
                fb.Feedback = feedback;
                fb.League = league;
                fb.Email = email;
                fb.FeedbackTypeEnum = (byte)FeedbackTypeEnum.None;
                db.ScoreboardFeedback.Add(fb);
                db.SaveChanges();

                string body = "New Feedback Boss:<br/><br/>";
                body += feedback + "<br/><br/>";
                body += "from: " + email + "<br/>";
                body += "url: http://raspberry.rdnation.com/Admin/Feedback<br/>";
                body += "You Da Man!";


                var emailData = new Dictionary<string, string> { { "body", body } };
                EmailServer.EmailServer.SendEmail(ServerConfig.DEFAULT_EMAIL, ServerConfig.DEFAULT_EMAIL_FROM_NAME, ServerConfig.DEFAULT_INFO_EMAIL, EmailServer.EmailServer.DEFAULT_SUBJECT + " New Feedback", emailData, layout: EmailServerLayoutsEnum.Blank, priority: EmailPriority.Normal);
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
        }
开发者ID:mukhtiarlander,项目名称:git_demo_torit,代码行数:31,代码来源:ScoreboardFeedback.cs

示例11: insertAssistIntoDb

        public static int insertAssistIntoDb(Guid teamId, GameViewModel game, AssistViewModel assisted, ManagementContext db, DataModels.Game.Game g)
        {
            int c = 0;
            try
            {
                GameMemberAssist assist = new GameMemberAssist();
                assist.DateTimeAssisted = assisted.CurrentDateTimeAssisted;
                assist.GameAssistId = assisted.AssistId;
                assist.JamNumber = assisted.JamNumber;
                assist.JamId = assisted.JamId;
                assist.PeriodNumber = assisted.Period;
                assist.PeriodTimeRemainingMilliseconds = assisted.PeriodTimeRemaining;
                assist.Game = g;

                assist.MemberWhoAssisted = g.GameTeams.Where(x => x.TeamId == teamId).First().GameMembers.Where(x => x.GameMemberId == assisted.PlayerWhoAssisted.SkaterId).FirstOrDefault();
                if (assist.MemberWhoAssisted != null)
                {
                    db.GameMemberAssist.Add(assist);
                    c += db.SaveChanges();
                }
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return c;
        }
开发者ID:mukhtiarlander,项目名称:git_demo_torit,代码行数:27,代码来源:GameAssistsClass.cs

示例12: DeleteFolderFromLeague

 public static bool DeleteFolderFromLeague(Guid leagueId, long folderId)
 {
     try
     {
         var dc = new ManagementContext();
         var fold = dc.LeagueDocumentFolders.Where(x => x.League.LeagueId == leagueId && x.CategoryId == folderId).FirstOrDefault();
         if (fold != null)
         {
             fold.ParentFolder = null;
             var docs = dc.LeagueDocuments.Where(x => x.Category.CategoryId == folderId);
             foreach (var doc in docs)
             {
                 doc.Category = null;
             }
             dc.LeagueDocumentFolders.Remove(fold);
             int c = dc.SaveChanges();
             return c > 0;
         }
     }
     catch (Exception exception)
     {
         ErrorDatabaseManager.AddException(exception, exception.GetType());
     }
     return false;
 }
开发者ID:mukhtiarlander,项目名称:git_demo_torit,代码行数:25,代码来源:LeagueFolder.cs

示例13: EditLeagueContact

        public static bool EditLeagueContact(Guid leagueId, ContactDisplayBasic contact)
        {
            try
            {
                var dc = new ManagementContext();
                var con = dc.LeagueContacts.Where(x => x.Contact.ContactId == contact.ContactId).FirstOrDefault();

                con.Contact.CompanyName = contact.CompanyName;
                con.Contact.Firstname = contact.FirstName;
                con.Contact.Lastname = contact.LastName;
                con.Contact.Link = contact.Link;

                int countryId = Convert.ToInt32(contact.CountryId);
                ContactCard.ContactCardFactory.UpdateAddressToContact(contact.Address1, contact.Address2, contact.CityRaw, contact.StateRaw, contact.Zip, AddressTypeEnum.None, con.Contact.ContactCard, dc.Countries.Where(x => x.CountryId == countryId).FirstOrDefault());
                ContactCard.ContactCardFactory.UpdatePhoneNumberToCard(contact.PhoneNumber, con.Contact.ContactCard, String.Empty);
                ContactCard.ContactCardFactory.UpdateEmailToContactCard(contact.Email, con.Contact.ContactCard);
                
                con.Notes = contact.Notes;
                con.ContactTypeEnum = (byte)((ContactTypeForOrganizationEnum)Enum.Parse(typeof(ContactTypeForOrganizationEnum), contact.ContactTypeSelected));
                con.League = con.League;
                con.Contact = con.Contact;
                int c = dc.SaveChanges();
                return c > 0;
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return false;
        }
开发者ID:mukhtiarlander,项目名称:git_demo_torit,代码行数:30,代码来源:Contact.cs

示例14: Add_New_List

        public static bool Add_New_List(RDN.Library.Classes.League.TaskList.TaskListDA NewTaskList)
        {

            try
            {
                var dc = new ManagementContext();
                DataModels.League.Task.TaskList con = new DataModels.League.Task.TaskList();
                con.AssignedTo = NewTaskList.AssignedTo;
                con.EndDate = NewTaskList.EndDate;
                con.ListAddByMember = dc.Members.Where(x => x.MemberId == NewTaskList.ListAddByMember).FirstOrDefault();
                con.ListName = NewTaskList.ListName;
                con.TaskListForLeague = dc.Leagues.Where(x => x.LeagueId == NewTaskList.TaskListForLeague).FirstOrDefault();

                dc.TaskLists.Add(con);

                int c = dc.SaveChanges();

                return c > 0;

            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());

            }
            return false;
        }
开发者ID:mukhtiarlander,项目名称:git_demo_torit,代码行数:27,代码来源:TaskListDA.cs

示例15: UpdateLocations

        public static void UpdateLocations()
        {
            var dc = new ManagementContext();
            var adds = dc.Addresses;
            foreach (var add in adds)
            {
                try
                {
                    var coords = OpenStreetMap.FindLatLongOfAddress(add.Address1, add.Address2, add.Zip, add.CityRaw, add.StateRaw, add.Country != null ? add.Country.Name : String.Empty);
                    if (coords != null)
                    {
                        add.Coords = new System.Device.Location.GeoCoordinate();
                        add.Coords.Latitude = coords.Latitude;
                        add.Coords.Longitude = coords.Longitude;
                        add.Coords.Altitude = 0;
                        add.Coords.Course = 0;
                        add.Coords.HorizontalAccuracy = 1;
                        add.Coords.Speed = 0;
                        add.Coords.VerticalAccuracy = 1;
                    }
                    add.ContactCard = add.ContactCard;


                }
                catch (Exception exception)
                {
                    ErrorDatabaseManager.AddException(exception, exception.GetType());
                }
            }
            dc.SaveChanges();

        }
开发者ID:mukhtiarlander,项目名称:git_demo_torit,代码行数:32,代码来源:Location.cs


注:本文中的RDN.Library.DataModels.Context.ManagementContext.SaveChanges方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。