public async Task UpdateViewCount()
        {
            var request = new EpisodeUserActivityRequest {
                EpisodeId = Episode.Id, UserId = APIService.LoggedUser.Id
            };
            var episode = await _episodeApiService.Update <MEpisode>(Episode.Id, request);

            if (!APIService.LoggedUser.WatchedEpisodes.Select(x => x.Id).Contains(Episode.Id))
            {
                APIService.LoggedUser.WatchedEpisodes.Add(episode);
            }
        }
Exemplo n.º 2
0
        public MEpisode Update(int id, EpisodeUserActivityRequest request)
        {
            var episode = ctx.Episodes.Find(id);

            episode.Viewcount += 1;
            ctx.SaveChanges();

            var activityCheck = ctx.UserEpisodeActivities?.Where(x => x.EpisodeId == request.EpisodeId && x.UserId == request.UserId)?.FirstOrDefault();

            if (activityCheck == null)
            {
                var newRecord = new UserEpisodeActivity {
                    EpisodeId = request.EpisodeId, UserId = request.UserId
                };
                ctx.UserEpisodeActivities.Add(newRecord);
                ctx.SaveChanges();
            }
            return(_mapper.Map <MEpisode>(episode));
        }
 public MEpisode Update(int id, EpisodeUserActivityRequest request) => _service.Update(id, request);