예제 #1
0
        public static async Task <FriendViewModel> CreateFriendRequestOnServer(User user)
        {
            FriendViewModel addedFriend     = null;
            Exception       friendException = null;

            try
            {
                var friend = new Friend {
                    UserId = user.UserId
                };
                var friendsTable = App.MobileService.GetTable <Friend>();
                await friendsTable.InsertAsync(friend);

                addedFriend = friend.AsViewModel();
            }
            catch (Exception ex)
            {
                friendException = ex;
            }

            if (friendException != null)
            {
                var errorData = new LimitedCrashExtraDataList();
                errorData.Add("Message", string.Format("Failed to create Friend relationship between {0} & {1}",
                                                       App.MobileService.CurrentUser.UserId, user.UserId));
                BugSenseHandler.Instance.UserIdentifier = App.MobileService.CurrentUser.UserId;
                await BugSenseHandler.Instance.LogExceptionAsync(friendException, errorData);
            }
            return(addedFriend);
        }