Exemple #1
0
        public async Task <IActionResult> AddToWatching(string id, [FromBody] AddToHistory model)
        {
            var show = await _omdbApi.GetById(id);

            if (show.Type == ShowType.Episode)
            {
                return(AddEpisodeToWatching(id, model));
            }

            var existingStatus = _watchlistService.GetStatusForShow(CurrentUserId, id);

            if (existingStatus == WatchStatus.InProgress || existingStatus == WatchStatus.Completed)
            {
                return(BadRequest("The show is already in progress or completed."));
            }

            _watchlistService.AddToHistory(CurrentUserId, id, model.WatchStatus);

            return(Ok(_watchlistService.GetStatusForShow(CurrentUserId, id)));
        }