private async Task SetLike(CStatisticNews isLike, CStatisticNews isDislike, CStatisticNews isViews, CProfile user, CNews news, string link) { if (isLike == null) { if (isDislike == null) { if (isViews == null) { await context .StatisticNews .AddAsync(new CStatisticNews { News = news, Like = user, ViewBy = user, IsNotifyed = true }); if (user.Id != news.Owner.Id) { await SetNotificationAsync(user, news, link); } } else { if (!isViews.IsNotifyed && user.Id != news.Owner.Id) { await SetNotificationAsync(user, news, link); isViews.IsNotifyed = true; } isViews.Like = user; context.StatisticNews.Update(isViews); } } else { if (!isDislike.IsNotifyed && user.Id != news.Owner.Id) { await SetNotificationAsync(user, news, link); isDislike.IsNotifyed = true; } isDislike.Dislike = null; isDislike.Like = user; context.StatisticNews.Update(isDislike); } } else { isLike.Like = null; context.StatisticNews.Update(isLike); } }
private async Task SetView(CStatisticNews isViews, CProfile user, CNews news) { if (isViews == null) { await context .StatisticNews .AddAsync(new CStatisticNews { News = news, Like = null, ViewBy = user }); } }
private async Task SetDislike(CStatisticNews isDislike, CStatisticNews isLike, CStatisticNews isViews, CProfile user, CNews news) { if (isDislike == null) { if (isLike == null) { if (isViews == null) { await context .StatisticNews .AddAsync(new CStatisticNews { News = news, Dislike = user, ViewBy = user }); } else { isViews.Dislike = user; context.StatisticNews.Update(isViews); } } else { isLike.Like = null; isLike.Dislike = user; context.StatisticNews.Update(isLike); } } else { isDislike.Dislike = null; context.StatisticNews.Update(isDislike); } }