コード例 #1
0
        public async Task <MemeVM> MapMemeVM(Meme entity, System.Security.Claims.ClaimsPrincipal user)
        {
            MemeVM vm = new MemeVM();

            vm.MemeId   = entity.MemeId;
            vm.Title    = entity.Title;
            vm.UserId   = entity.UserID;
            vm.UserName = entity.PageUser.UserName;
            vm.ByteHead = entity.ByteHead;
            vm.ByteImg  = entity.ImageByte;
            vm.Category = await _categoryService.GetCategoryVM(entity.CategoryId);

            vm.CreationDate = entity.CreationDate.ToString("dd/MM/yyyy");
            vm.Rate         = entity.Rate();
            vm.CommentCount = entity.CommentCount();
            vm.IsAccepted   = entity.IsAccepted;
            vm.IsArchived   = entity.IsArchived;
            vm.IsVoted      = false;
            vm.IsFavourite  = false;
            vm.VoteValue    = null;
            if (user != null && user.Identity.IsAuthenticated == true)
            {
                string userId = user.Claims.First(c => c.Type == "UserID").Value;
                vm.IsVoted     = entity.IsVoted(userId);
                vm.VoteValue   = entity.VoteValue(userId);
                vm.IsFavourite = entity.IsFavourite(userId);
            }
            return(vm);
        }
コード例 #2
0
        /// <summary>
        /// button -> Load memes by typed tittle
        /// </summary>
        public async Task <List <MemeVM> > LoadMemeByTitle()
        {
            MemeVM meme = await _memeService.GetMemesByTitle(SearchByNameProperty);

            Memes = new List <MemeVM>()
            {
                meme
            };
            return(Memes);
        }
コード例 #3
0
        public async Task <MemeVM> GetMemesByTitle(string searchByNameProperty)
        {
            dynamic client = await _restClientApp.Build();

            var result = await client.Memes.Query(new { title = searchByNameProperty }).Get();

            foreach (var meme in result)
            {
                Console.WriteLine(user.name);
            }

            string      image64 = result.image64;
            BitmapImage image   = image64.ToBitmapImage();

            MemeVM meme = new MemeVM()
            {
                Image = image,
                Title = result.title
            };

            return(meme);
        }