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)); }
/// <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)); }
/// <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; } }
public Task <Entities.Restaurante> PostRestauranteAsync(Entities.Restaurante restaurante) { return(_restauranteRepository.PostRestauranteAsync(restaurante)); }