예제 #1
0
        public async Task <IActionResult> Put(string id, string productId)
        {
            try
            {
                Customer updated = await _customerService.AddFavoriteProduct(id, productId);

                return(Ok(updated));
            }
            catch (NotFoundException exc)
            {
                _logger.LogError(exc.Message);
                return(NotFound(exc.Message));
            }
            catch (InvalidOperationException exc)
            {
                _logger.LogError(exc.Message);
                return(BadRequest("Este produto já foi adicionado"));
            }
            catch (Exception exc)
            {
                _logger.LogError(exc.Message);
                return(StatusCode(500, exc.Message));
            }
        }