public IActionResult Update([FromBody] Restaurantes rs, [FromServices] RestaurantesService service) { if (ModelState.IsValid) { return(Ok(service.updateRestaurante(rs))); } else { return(BadRequest(ModelState)); } }
public void QueryByNome_NomeInexistente_RetornaListaVazia() { using (var context = new Context(Util.GetDbOptions())) { // Arrange CarregaRestaurantes(context); var restaurantesService = new RestaurantesService(context); // Act var retorno = restaurantesService.QueryByNome("AnTe 10"); // Assert Assert.Empty(retorno); } }
public void QueryByNome_NomeExistenteSemMatchCase_RetornaRestaurantes() { using (var context = new Context(Util.GetDbOptions())) { // Arrange CarregaRestaurantes(context); var restaurantesService = new RestaurantesService(context); // Act var retorno = restaurantesService.QueryByNome("AnTe 2").ToList(); // Assert Assert.Single(retorno); Assert.Equal(2, retorno.First().Id); Assert.Equal("Restaurante 2", retorno.First().Nome); } }
public void QueryByNome_NomeEmBranco_RetornaTodos() { using (var context = new Context(Util.GetDbOptions())) { // Arrange CarregaRestaurantes(context); var restaurantesService = new RestaurantesService(context); // Act var retorno = restaurantesService.QueryByNome(string.Empty).ToList(); // Assert Assert.Equal(3, retorno.Count()); Assert.Equal(1, retorno.ElementAt(0).Id); Assert.Equal(2, retorno.ElementAt(1).Id); Assert.Equal(3, retorno.ElementAt(2).Id); } }
public IActionResult GetRestaurantesByCidade(string cidade, Guid idUsuario, [FromServices] RestaurantesService service) { return(Ok(service.GetRestaurantesByCidade(cidade, idUsuario))); }
public IActionResult GetRestaurantesById(Guid idUsuario, [FromServices] RestaurantesService service) { return(Ok(service.GetRestaurantesById(idUsuario))); }
public IActionResult Delete(Guid id, [FromServices] RestaurantesService service) { return(Ok(service.DeleteRestauranteById(id))); }
public IActionResult GetMunicipios(string estado, [FromServices] RestaurantesService service) { return(Ok(service.GetMunicipios(estado))); }
public IActionResult GetEstados([FromServices] RestaurantesService service) { return(Ok(service.GetUfs())); }
public RestauranteController(RestaurantesService restaurantesService) { _restaurantesService = restaurantesService; }