Example #1
0
        public static void UpdateGoogleMilesUri(int originKey, Dictionary <int, string> lookupDestinationDict, bool updateAll = false)
        {
            int destKey = 0;

            //bool updateAll = UpdateAll.IsChecked.Value;
            using (var mdc = new MilesDataContext())
            {
                foreach (var dest in lookupDestinationDict)
                {
                    destKey = dest.Key;

                    //Get the Mile Record
                    var mRec = from mtable in mdc.Miles
                               where mtable.FromId == originKey && mtable.ToId == destKey
                               select mtable;
                    foreach (Mile mile in mRec)
                    {
                        mile.GoogleUri = GoogleHelper.CreateGoogleMilesTableLink(originKey, mile.ToId);
                    }

                    //Submit changes to table
                    try
                    {
                        mdc.SubmitChanges();
                    }
                    catch (Exception exceptUpdate)
                    {
                        MessageBox.Show(exceptUpdate.Message.ToString());
                    }
                }
            }
        }