Esempio n. 1
0
 private void UpdateLocateBuddy(LocateBuddyTableEntity buddy)
 {
     //BL: Delete buddies who are removed - Do this one time while loading the app asynchronously and update ISO
     //BL: Refresh status changes and add new Locate Buddies
     try
     {
         if (this.LocateBuddies.Any(b => b.BuddyProfileId == buddy.BuddyProfileId))
         {
             var buddyItem = this.LocateBuddies.First(b => b.BuddyProfileId == buddy.BuddyProfileId);
             buddyItem.Name             = buddy.Name;
             buddyItem.BorderThickness  = buddy.BorderThickness;
             buddyItem.OrderNumber      = buddy.OrderNumber;
             buddyItem.BuddyStatusColor = buddy.BuddyStatusColor;
         }
         else
         {
             this.LocateBuddies.Add(buddy);
             //Save to local storage
             _dataContext.LocateBuddiesTable.InsertOnSubmit(buddy);
             _dataContext.SubmitChanges();
         }
     }
     catch (Exception ex)
     { }
 }
Esempio n. 2
0
        private void GetLocateMembersList(ProfileLiteList oLocateMembersList)
        {
            try
            {
                if (oLocateMembersList == null && LocationServiceWrapper.IsErrorOccured == true)
                {
                    this.Message = "We are having issues in retrieving your data. Please try again later.";
                }
                else if ((oLocateMembersList == null || oLocateMembersList.List == null || oLocateMembersList.List.Count == 0) && (this.LocateBuddies.Count < 1))
                {
                    this.Message = "You have no buddies to track.";
                    ClearLocateBuddies();
                }
                else if (oLocateMembersList != null && oLocateMembersList.List != null)
                {
                    foreach (var item in oLocateMembersList.List)//.OrderByDescending(b => b.IsSOSOn).ThenByDescending(b => b.IsTrackingOn))
                    {
                        string backStatusColor = item.IsSOSOn ? Constants.SaffronColorCode : (item.IsTrackingOn ? Constants.GreenColorCode : Constants.WhiteColorCode);
                        int    order           = item.IsSOSOn ? 6 : (item.IsTrackingOn ? 4 : 2);//These numbers are used for Border Thickness as well.
                        var    buddy           = new LocateBuddyTableEntity()
                        {
                            BuddyProfileId = item.ProfileID.ToString(), Name = item.Name, Email = item.Email, PhoneNumber = item.MobileNumber, BuddyStatusColor = backStatusColor, TrackingToken = item.SessionID, OrderNumber = order, BorderThickness = new Thickness(order)
                        };

                        UpdateLocateBuddy(buddy);

                        if (item.LastLocs != null && item.LastLocs.Count > 0)
                        {
                            GetLocationAddressAsync(item.LastLocs, item.ProfileID.ToString());//TODO: Optimize
                        }
                    }

                    if (this.LocateBuddies.Count > 0)
                    {
                        if (this.LocateBuddies.Count != oLocateMembersList.List.Count)
                        {
                            DeleteLocateBuddies(oLocateMembersList.List);
                        }

                        this.LocateBuddies.Sort(b => b.OrderNumber, ListSortDirection.Descending);
                    }
                }
            }
            catch (Exception)
            {
                CallErrorHandler();
            }
            IsInProgress = false;
        }