Exemplo n.º 1
0
        /// <summary>
        /// Método responsável por alterar um RestauranteHistorico
        /// </summary>
        /// <param name="restauranteHistorico">Objeto RestauranteHistorico</param>
        /// <returns>Objeto RestauranteHistorico</returns>
        public async Task <RestauranteHistorico> PutRestauranteHistoricoAsync(RestauranteHistorico restauranteHistorico)
        {
            try
            {
                _dbContext.SetModified(restauranteHistorico);
                await _dbContext.SaveChangesAsync();

                return(restauranteHistorico);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Método responsável por inserir um novo RestauranteHistorico
        /// </summary>
        /// <param name="restauranteHistorico">Objeto RestauranteHistorico</param>
        /// <returns>Objeto RestauranteHistorico</returns>
        public async Task <RestauranteHistorico> PostRestauranteHistoricoAsync(RestauranteHistorico restauranteHistorico)
        {
            try
            {
                if (!restauranteHistorico.ValidarEntidade())
                {
                    throw new Exception("Restaurante histórico inválido.");
                }

                _dbContext.Add(restauranteHistorico);
                await _dbContext.SaveChangesAsync();

                return(restauranteHistorico);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }