public async Task <ActionResult> AddLike([FromBody] ChapterLikeViewModel like)
        {
            try
            {
                if (like == null)
                {
                    logger.LogError($"Like object sent from client is null");
                    return(BadRequest("Like object is null"));
                }

                await likesAdapter.AddLike(like).ConfigureAwait(false);

                logger.LogInformation($"Like added to the chapter with id: {like.ChapterId} is successfully added");
                return(Ok());
            }
            catch (Exception ex)
            {
                logger.LogError($"Something went wrong inside AddLike action: {ex.Message}");
                return(StatusCode(500, "Internal server error"));
            }
        }
Exemple #2
0
 public async Task AddLike(ChapterLikeViewModel like)
 {
     await likesService.CreateAsync(mapper.Map <ChapterLike>(like)).ConfigureAwait(false);
 }