Beispiel #1
0
        public Task <Entities.Restaurante> PutRestauranteAsync(Entities.Restaurante restaurante)
        {
            var restauranteExistente = _restauranteRepository.GetRestauranteAsync(restaurante.IdRestaurante);

            if (restauranteExistente == null)
            {
                throw new ElementoNaoEncontratoException("Restaurante não encontrado.");
            }

            return(_restauranteRepository.PutRestauranteAsync(restaurante));
        }
Beispiel #2
0
        /// <summary>
        /// Método responsável por alterar um Restaurante
        /// </summary>
        /// <param name="restaurante">Objeto Restaurante</param>
        /// <returns>Objeto Restaurante</returns>
        public async Task <Entities.Restaurante> PutRestauranteAsync
            (Entities.Restaurante restaurante)
        {
            try
            {
                _dbContext.SetModified(restaurante);
                await _dbContext.SaveChangesAsync();

                return(restaurante);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public async Task <IActionResult> PutRestaurante(Entities.Restaurante restaurante)
        {
            var response = new ResponseContent();

            try
            {
                response.Object = await _restauranteUoW.restauranteBLL.PutRestauranteAsync(restaurante);

                response.Message = "Requisição realizada com sucesso.";
                response.Status  = true;
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
                response.Status  = false;
            }

            return(Ok(response));
        }
Beispiel #4
0
        /// <summary>
        /// Método responsável por inserir um novo usuário
        /// </summary>
        /// <param name="restaurante">Objeto usuário</param>
        /// <returns>Objeto usuário</returns>
        public async Task <Entities.Restaurante> PostRestauranteAsync
            (Entities.Restaurante restaurante)
        {
            try
            {
                if (!restaurante.ValidarEntidade())
                {
                    throw new Exception("Restaurante inválido.");
                }

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

                return(restaurante);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #5
0
 public Task <Entities.Restaurante> PostRestauranteAsync(Entities.Restaurante restaurante)
 {
     return(_restauranteRepository.PostRestauranteAsync(restaurante));
 }