Example #1
0
        private void ChangePhoto() // changed form 'private'
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            if (openFileDialog.ShowDialog() == true)
            {
                var fileName = openFileDialog.FileName;
                if (!string.IsNullOrEmpty(fileName))
                {
                    WebClient client = new WebClient();
                    byte[]    result = client.UploadFile(SocialNetwork.Web.WebApiWrapper.Services.BaseService.Host + Resources.ImageCreatePath, fileName);
                    var       strID  = System.Text.Encoding.Default.GetString(result);
                    var       res    = strID.Substring(1, strID.Length - 2);
                    var       id     = new Guid(res);

                    var image = imageService.Create(id, currentSession.LoggedUser.Id);
                    currentSession.LoggedUser.ProfilePhotoId = image.Id;
                    var imageUrl = profilePhotoService.GetProfilePhoto(currentSession.LoggedUser.ProfilePhotoId).Url;
                    if (imageUrl.Contains(@"\Resources\images\ProfilePhotos"))
                    {
                        ImageSource = imageUrl;
                    }
                    else
                    {
                        // ImageSource = profilePhotoService.GetProfilePhoto(currentSession.LoggedUser.ProfilePhotoId).Url;
                        ImageSource = imageUrlService.GetImageUrl(currentSession.LoggedUser.ProfilePhotoId);
                    }
                }
            }
        }
Example #2
0
        public UserProfileViewModel(
            MessageHistoryService messageHistoryServ,
            UserSearcher userSearchingServ,
            FriendsService friendServ,
            Messanger mesServ,
            SessionInfo session,
            MessageSearcher mesSerServ,
            Services.PhotoService.UsersPhotoService profilePhotoService,
            ImageService imageServ,
            Authenticator authenticatorServ,
            ImageUrlService imageUrlServ)
        {
            Messages                 = new FlowDocument();
            controlsVisibility       = false;
            canExecute               = true;
            CurrentSession           = session;
            messageHistoryService    = messageHistoryServ;
            userSearchingService     = userSearchingServ;
            friendService            = friendServ;
            this.profilePhotoService = profilePhotoService;
            imageService             = imageServ;
            Friends = friendService.GetFriends(currentSession.LoggedUser.Id).ResultTask.Result;
            authenticatorService = authenticatorServ;
            imageUrlService      = imageUrlServ;

            FindFriendEmailOrLogin = string.Empty;
            messengerService       = mesServ;
            DocWidth = 248;
            FontSize = 13;
            messageSearchingService = mesSerServ;
            var imageUrl = profilePhotoService.GetProfilePhoto(currentSession.LoggedUser.ProfilePhotoId).Url;

            if (imageUrl.Contains(@"\Resources\images\ProfilePhotos"))
            {
                ImageSource = imageUrl;
            }
            else
            {
                ImageSource = imageUrlService.GetImageUrl(currentSession.LoggedUser.ProfilePhotoId);
            }
        }