示例#1
0
        public async Task Include(long customerId, FavoritePut favoritePut)
        {
            var customer = await _customers.GetById(customerId);

            if (customer == null)
            {
                throw new Exception("CLIENTE não encontrado.");
            }

            var product = await _products.GetById(favoritePut.ProductId);

            if (customer.FavoritiesProducts.Any(x => x.Id == favoritePut.ProductId))
            {
                throw new Exception("PRODUTO já cadastrado como favorito.");
            }

            await _customers.IncludeFavorite(customer, product);
        }