Example #1
0
        public void ClearLocateBuddies()
        {
            var locateBuddies = from LocateBuddyTableEntity lb in _dataContext.LocateBuddiesTable
                                select lb;

            _dataContext.LocateBuddiesTable.DeleteAllOnSubmit(locateBuddies);
            _dataContext.SubmitChanges();
        }
Example #2
0
        public void AddProfile(ProfileTableEntity newProfile)
        {
            _dataContext.MyProfilesTable.InsertOnSubmit(newProfile);
            _dataContext.SubmitChanges();

            this.CurrentProfile = newProfile;
        }
Example #3
0
        public void CreateDefaultUser()
        {
            UserTableEntity user = new UserTableEntity();

            //user.IsDataSynced = true;
            user.CurrentProfileId = "0";

            _dataContext.UserTable.InsertOnSubmit(user);
            _dataContext.SubmitChanges();

            this.User = user;
        }
Example #4
0
        public void AddBuddy(BuddyTableEntity newBuddy)
        {
            IsSuccess = true;
            Message   = string.Empty;

            try
            {
                var buddyInLocalStore = (from BuddyTableEntity buddy in _dataContext.MyBuddiesTable
                                         where (buddy.PhoneNumber != "" && buddy.PhoneNumber == newBuddy.PhoneNumber) ||
                                         (buddy.Email != "" && buddy.Email == newBuddy.Email)
                                         select buddy).FirstOrDefault();

                if (buddyInLocalStore != null)
                {
                    buddyInLocalStore.IsDeleted = false;
                }
                else
                {
                    _dataContext.MyBuddiesTable.InsertOnSubmit(newBuddy);
                }

                _dataContext.SubmitChanges();
                this.Buddies.Add(newBuddy);
            }
            catch (Exception ex)
            {
                IsSuccess = false;
                Message   = ex.Message;
            }
        }
Example #5
0
        private async void GetLocationAddressAsync(ObservableCollection <GeoTag> locationTag, string profileId)
        {
            try
            {
                string address = await Utility.GetCombOfBingAndGMapsAddress(locationTag[0].Lat, locationTag[0].Long);

                if (this.LocateBuddies.Any(b => b.BuddyProfileId == profileId))
                {
                    this.LocateBuddies.First(b => b.BuddyProfileId == profileId).LastLocation = "@ " + address + " - " + new DateTime(locationTag[0].TimeStamp).ToString("dd/MM/yyyy HH:mm:ss");

                    using (var dataContext = new SOSDataContext(SOSDataContext.DBConnectionString))
                    {
                        if (dataContext.LocateBuddiesTable.Count() > 0)
                        {
                            //TODO: Bug - if uses Single, then it is throwing error. This means there are multiple entries in LocateBuddies with Same buddyId
                            dataContext.LocateBuddiesTable.First(b => b.BuddyProfileId == profileId).LastLocation = "( was at " + address + " - " + new DateTime(locationTag[0].TimeStamp).ToString("dd/MM/yyyy HH:mm:ss") + ")";
                            dataContext.SubmitChanges();
                        }
                    }
                }
            }
            catch
            {
                //absorb exception occurred while getting address
            }
        }
Example #6
0
        public void AddGroup(GroupTableEntity newGroup)
        {
            IsSuccess = true;
            Message   = string.Empty;

            try
            {
                var groupInLocalStore = (from GroupTableEntity g in _dataContext.MyGroupsTable
                                         where g.GroupId == newGroup.GroupId
                                         select g).FirstOrDefault();

                if (groupInLocalStore != null)
                {
                    groupInLocalStore.IsDeleted = false;
                }
                else
                {
                    _dataContext.MyGroupsTable.InsertOnSubmit(newGroup);
                }

                _dataContext.SubmitChanges();
                this.Groups.Add(newGroup);
            }
            catch (Exception ex)
            {
                IsSuccess = false;
                Message   = ex.Message;
            }
        }