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); }
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); }
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); }
public void Dislike(DtoLike dtoLike) { this.modelFeedService.Dislike(dtoLike.id); // Получаем контекст хаба var cntxt = Microsoft.AspNet.SignalR.GlobalHost.ConnectionManager.GetHubContext <FeedHub>(); // отправляем сообщение cntxt.Clients.All.unlike(dtoLike); }
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); }
public void Update(DtoLike entity) { throw new NotImplementedException(); }
public IActionResult Likeoperation(DtoLike entity) { like.Create(entity); return(Json(true)); }