Пример #1
0
        /// <summary>
        /// Gets the value of this member as a string.
        /// </summary>
        /// <param name="item">The instance from which to get this member value.</param>
        /// <returns>The member value.</returns>
        public string GetValue(object item)
        {
            Debug.Assert(Member != null);
            Debug.Assert(Converter != null);

            return(Member.CanRead ? Converter.ConvertToString(Member.GetValue(item)) : string.Empty);
        }
Пример #2
0
        public SinglePostViewModel BuildPostViewModel(int id)
        {
            var post = _postRepository.GetPost(id);

            var model = new SinglePostViewModel()
            {
                Author       = post.Author,
                AuthorAvatar = _imageRepository.GetImageInString(post.AuthorId),
                AuthorId     = post.AuthorId,
                Content      = post.Content,
                Id           = post.Id,
                Title        = post.Title,
                PostedAt     = post.PostedAt,
                Rank         = post.Rank,
                SubTitle     = post.SubTitle
            };

            if (post.postPicture != null)
            {
                model.PostImage = _dataConverter.ConvertToString(post.postPicture.PostImageInBytes);
            }
            else
            {
                model.PostImage = string.Empty;
            }
            return(model);
        }
        public async Task <string> Decrypt(Key key, string dataToDecrypt, IDataConverter dataConverter)
        {
            try
            {
                var byteData = dataConverter.ConvertToByteArray(dataToDecrypt);
                var result   = await this.keyVaultClient.DecryptDataAsync(key.KeyIdentifier, "RSA_OAEP", byteData);

                return(dataConverter.ConvertToString(result.Result));
            }
            catch (Exception e)
            {
                return(e.Message);
            }
        }
Пример #4
0
        public string GetImageInString(string userID)
        {
            byte[] avatarInBytes;
            string avatarInString;
            var    db = _dbContext.GetDBContext();

            if (!db.Users.Where(x => x.Id == userID).Any())
            {
                return(string.Empty);
            }
            var currentUser = db.Users.Where(x => x.Id == userID).Single();

            if (currentUser.Avatar != null)
            {
                avatarInBytes  = currentUser.Avatar.AvatarInBytes;
                avatarInString = _fileController.ConvertToString(avatarInBytes);
            }
            else
            {
                avatarInString = null;
            }

            return(avatarInString);
        }