Exemple #1
0
        public ExecuteResult <ShowCustomerInfoResponse> GetShowCustomer(ShowCustomerRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }

            var entity = _customerRepository.GetItem(request.UserId);

            if (entity == null)
            {
                return(new ExecuteResult <ShowCustomerInfoResponse>(null));
            }

            var userModel = MappingManager.UserModelMapping(entity);

            var response = MappingManager.ShowCustomerInfoResponseMapping(userModel);

            if (request.CurrentAuthUser != null)
            {
                //取是否关注当前
                var likeEntity = _likeService.Get(request.CurrentAuthUser.Id, request.UserId);
                response.IsLiked = likeEntity != null;
            }
            return(new ExecuteResult <ShowCustomerInfoResponse>(response));
        }
        public IActionResult BlogDetail(int id)
        {
            Blog        blog    = blogService.Get(x => x.id == id && x.IsActive);
            SessionUser session = userSessionService.Get("LoginUser");
            string      color   = "#6c757d";

            if (EntityBase.IsNotNull(blog) && EntityBase.IsNotNull(session))
            {
                Like like = likeService.Get(x => x.IsActive == true && x.Userid == session.id && x.Blogid == blog.id);
                if (EntityBase.IsNotNull(like))
                {
                    color = like.IsLike ? "#9494FF" : "#FF8b60";
                }
                BlogViewCounterModel blogViewCounterModel = blogViewCounterCookieService.Get($"BlogView-{blog.id}-{session.id}");
                if (blogViewCounterModel == null)
                {
                    blog.ViewCount++;
                    blogService.Update(blog);
                    blogService.Save();
                    blogViewCounterCookieService.Set($"BlogView-{blog.id}-{session.id}", new BlogViewCounterModel()
                    {
                        Blogid  = blog.id,
                        Userid  = session.id,
                        IsLogin = true
                    }, 60 * 2);
                }
            }
            else
            {
                BlogViewCounterModel blogViewCounterModel = blogViewCounterCookieService.Get($"BlogView-{blog.id}-0");
                if (blogViewCounterModel == null)
                {
                    blog.ViewCount++;
                    blogService.Update(blog);
                    blogService.Save();
                    blogViewCounterCookieService.Set($"BlogView-{blog.id}-0", new BlogViewCounterModel()
                    {
                        Blogid  = blog.id,
                        IsLogin = false
                    }, 60 * 2);
                }
            }
            ViewBag.PointColor = color;
            return(View(blog));
        }
        public IActionResult DisLikePost(Guid postId)
        {
            try
            {
                var currentUserId = User.FindFirst(ClaimTypes.NameIdentifier).Value;
                if (_postService.DisLike(postId))
                {
                    //dislike sorunlu

                    var dislike = _likeService.Get(i => i.BegenenId == Guid.Parse(currentUserId) && i.PostId == postId);

                    _likeService.Delete(dislike);
                    return(Ok("Dislike Başarılı"));
                }
                else
                {
                    return(NotFound("Dislike başarısız."));
                }
            }
            catch (Exception e)
            {
                return(BadRequest(e));
            }
        }