Ejemplo n.º 1
0
        public IActionResult Post([FromBody] DtoFavourite saveFavourite)
        {
            var userEmail = User.FindFirst(ClaimTypes.NameIdentifier).Value;

            var userId = userRepository.GetUserId(userEmail);

            if (repository.Any(saveFavourite.RoomId, userId))
            {
                return(BadRequest("The favourite already exists."));
            }

            var favourite = new Favourite
            {
                AppUserId = userId,
                RoomId    = saveFavourite.RoomId
            };

            repository.Add(favourite);
            return(Ok(favourite));
        }