示例#1
0
        public IEnumerable <DtoFeed> GetFeed()
        {
            var dtoFeed = new List <DtoFeed>();

            var feed = feedRepo.GetAll().ToList();

            foreach (var f in feed)
            {
                var dtoLikes = new List <DtoLike>();
                //var likes = likeRepo.Where(l => l.FeedId == f.Id);
                foreach (var l in f.Likes)
                {
                    var dtoLike = new DtoLike()
                    {
                        id          = l.Id,
                        feedId      = l.FeedId,
                        profileName = l.Profile.Name
                    };
                    dtoLikes.Add(dtoLike);
                }
                dtoFeed.Add(new DtoFeed()
                {
                    name     = f.Profile.Name,
                    text     = f.Text,
                    date     = f.DateAdd.ToString(),
                    id       = f.Id,
                    parentId = f.ParentId,
                    likes    = dtoLikes
                });
            }

            return(dtoFeed);
        }
示例#2
0
        public DtoLike Dislike(int likeId)
        {
            var like  = new DtoLike();
            var model = likeRepo.FirstOrDefault(l => l.Id == likeId);

            like.feedId      = model.FeedId;
            like.profileName = model.Profile.Name;
            likeRepo.Delete(model);
            return(like);
        }
示例#3
0
        public int Like(DtoLike like)
        {
            var modelLike = new ModelLike()
            {
                FeedId    = like.feedId,
                ProfileId = profileRepo.FirstOrDefault(profile => profile.Name == like.profileName && profile.Token == like.token).Id
            };

            return(likeRepo.Add(modelLike).Id);
        }
示例#4
0
        public void Dislike(DtoLike dtoLike)
        {
            this.modelFeedService.Dislike(dtoLike.id);

            // Получаем контекст хаба
            var cntxt =
                Microsoft.AspNet.SignalR.GlobalHost.ConnectionManager.GetHubContext <FeedHub>();

            // отправляем сообщение
            cntxt.Clients.All.unlike(dtoLike);
        }
示例#5
0
        public void Create(DtoLike entity)
        {
            var gelen = Mapper.Map <Like>(entity);
            var sorgu = unit.Likerepo.GetLike(entity.TweetId).Where(x => x.UserId == entity.UserId).Select(x => x.Isdeleted == true).Any();

            if (sorgu == true)
            {
                unit.Likerepo.updatestate(gelen);
                unit.Save();
            }
            else
            {
                unit.Likerepo.Create(gelen);
                unit.Save();
            }
        }
        private async Task <ICollection <DtoLike> > usernameFinder(ICollection <Like> like)
        {
            ICollection <DtoLike> list = new List <DtoLike>();

            foreach (var likes in like)
            {
                var m = new DtoLike()
                {
                    CommentId = likes.CommentId,
                    LikeId    = likes.LikeId,
                    Comment   = likes.Comment,
                    UserId    = likes.UserId,
                    User      = likes.User,
                    UserName  = await userNameFindingMethod(likes.UserId)
                };
                list.Add(m);
            }

            return(list);
        }
示例#7
0
 public void Update(DtoLike entity)
 {
     throw new NotImplementedException();
 }
        public IActionResult Likeoperation(DtoLike entity)
        {
            like.Create(entity);

            return(Json(true));
        }