public void GetPratoById() { var controller = new PratoController(db); var pratoTest = repo.Where(r => r.Nome == "Prato1").FirstOrDefault(); var actionResult = controller.GetById(pratoTest.Id); var result = actionResult as OkObjectResult; Assert.IsNotNull(result); Assert.AreEqual(200, result.StatusCode); }
public IActionResult DeleteRestaurante([FromBody] int id) { try { var rest = repo.GetById(id); if (rest == null) { return(NotFound()); } foreach (var item in repoP.Where(p => p.RestauranteId == id).ToList()) { repoP.Delete(item); } repo.Delete(rest); } catch (Exception ex) { return(BadRequest(ex.InnerException.Message)); } return(Ok("Ok")); }