public EventoDetalle Get(string idEvento) { try { var id = Regex.Replace(idEvento, @"[^\d]", ""); return(EM.GetEvento(Int64.Parse(id))); } catch (Exception ex) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound) { Content = new StringContent(string.Format("Error: {0}", ex.Message)), ReasonPhrase = (ex.GetType() == typeof(ArgumentException) ? ex.Message : "Get_Error") }); } }
// POST http://apimyfootballteamnuevawebapp.azurewebsites.net/API/Eventos/Evento ?NombreEvento=Gol&Partido_IdPartido=39 // PUT http://apimyfootballteamnuevawebapp.azurewebsites.net/API/Eventos/Evento ?IdEvento=8&Minuto=1&NombreEvento=Gol&Partido_IdPartido=2&Jugador_IdJugador=-1 // GET http://apimyfootballteamnuevawebapp.azurewebsites.net/API/Eventos/Evento ?IdEvento=8 // DELETE http://apimyfootballteamnuevawebapp.azurewebsites.net/API/Eventos/Evento ?IdEvento=5 public JsonResult Evento(int?id, Evento item) { switch (Request.HttpMethod) { case "POST": return(Json(EventosManager.InsertEvento(item))); case "PUT": return(Json(EventosManager.UpdateEvento(item))); case "GET": return(Json(EventosManager.GetEvento(item), JsonRequestBehavior.AllowGet)); case "DELETE": return(Json(EventosManager.DeleteEvento(item))); } return(Json(new { Error = true, Messege = "Operación HTTP desconocida" })); }