The user data contract.
 protected AnnotationContract CreateTestAnnotation(UserContract fromUser, int goldCount, string photoId, string photoOwnerId, string text = "From Unit Test")
 {
     return new AnnotationContract
     {
         From = fromUser,
         GoldCount = goldCount,
         PhotoId = photoId,
         PhotoOwnerId = photoOwnerId,
         Text = text
     };
 }
 protected PhotoContract CreateTestPhoto(CategoryContract category, UserContract user, string description = "Test photo", int goldCount = 0)
 {
     return new PhotoContract
     {
         CategoryId = category.Id,
         CategoryName = category.Name,
         User = user,
         Description = description,
         OSPlatform = "test",
         HighResolutionUrl = "http://bing.com",
         StandardUrl = "http://bing.com",
         ThumbnailUrl = "http://bing.com",
         NumberOfGoldVotes = goldCount
     };
 }
 /// <summary>
 /// Updates the user profile picture.  User gold balance is also updated if it is the first time
 /// the user is updating their profile picture.
 /// </summary>
 /// <param name="user">We need the whole user object as it is assumed the client will have given the photoId and url.</param>
 /// <returns>A new UserContract object.</returns>
 public Task<UserContract> UpdateUser(UserContract user)
 {
     return _repository.UpdateUser(user);
 }
        /// <summary>
        /// Updates the user profile picture.  User gold balance is also updated if it is the first time
        /// the user is updating their profile picture.
        /// </summary>
        /// <param name="userContract">
        /// We need the whole user object as it is assumed the client will have given the photoId and
        /// url.
        /// </param>
        /// <returns>A new UserContract object.</returns>
        public async Task<UserContract> UpdateUser(UserContract userContract)
        {
            await ReplaceUserDocument(UserDocument.CreateFromContract(userContract));

            return userContract;
        }
 /// <summary>
 /// Creates a <see cref="UserDocument" /> from a <see cref="UserContract" />.
 /// </summary>
 /// <returns>The <see cref="UserDocument" />.</returns>
 public static UserDocument CreateFromContract(UserContract contract)
 {
     return new UserDocument
     {
         Id = contract.UserId,
         ProfilePhotoUrl = contract.ProfilePhotoUrl,
         ProfilePhotoId = contract.ProfilePhotoId,
         GoldBalance = contract.GoldBalance,
         RegistrationReference = contract.RegistrationReference,
         CreatedAt = new DateDocument
         {
             Date = contract.UserCreated
         },
         ModifiedAt = new DateDocument
         {
             Date = contract.UserModified
         }
     };
 }
 /// <summary>
 /// Creates a <see cref="AnnotationContract" /> from this document
 /// </summary>
 /// <param name="annotationOwner">The <see cref="UserContract" /> author of this annotation.</param>
 /// <param name="photoId">The id of the photo this annotation is for.</param>
 /// <param name="photoOwnerId">The id of the user that owns the photo this annotation is for.</param>
 /// <returns>The <see cref="AnnotationContract" />.</returns>
 public AnnotationContract ToContract(UserContract annotationOwner, string photoId, string photoOwnerId)
 {
     return new AnnotationContract
     {
         CreatedAt = CreatedDateTime.Date,
         Text = Text,
         Id = Id,
         GoldCount = GoldCount,
         From = annotationOwner,
         PhotoId = photoId,
         PhotoOwnerId = photoOwnerId
     };
 }
        public async Task<UserContract> UpdateUserProfile(UserContract user)
        {
            try
            {
                _telemetryClient.TrackEvent("UserController UpdateUserProfile invoked");

                var currentUserId = await ValidateAndReturnCurrentUserId();

                // A user should only be able to update his/her own profile.
                if (!currentUserId.Equals(user.RegistrationReference))
                {
                    throw ServiceExceptions.NotAllowed();
                }

                // Check if the user owns the photo that is passed in as profile photo
                var photo = await _repository.GetPhoto(user.ProfilePhotoId);

                if (!photo.User.UserId.Equals(user.UserId))
                {
                    throw ServiceExceptions.NotAllowed();
                }

                // Refreshing profile photo url
                user.ProfilePhotoUrl = photo.ThumbnailUrl;

                var existingUser = await _repository.UpdateUser(user);

                return existingUser;
            }
            catch (DataLayerException ex)
            {
                _telemetryClient.TrackException(ex);

                if (ex.Error == DataLayerError.Unknown)
                {
                    throw ServiceExceptions.UnknownInternalFailureException(ServiceExceptions.Source);
                }

                throw ServiceExceptions.DataLayerException(ex.Message);
            }
        }
 public Task<UserContract> UpdateUser(UserContract user)
 {
     throw new NotImplementedException();
 }