public HttpResponseMessage Post(Palestrante palestrante) { if (!ModelState.IsValid) return Request.CreateResponse(HttpStatusCode.BadRequest, ModelState); var app = Construtor.PalestranteAplicacaoMongo(); app.Salvar(palestrante); return Request.CreateResponse(HttpStatusCode.Created, palestrante); }
public HttpResponseMessage Put(string id, Palestrante palestrante) { if (!ModelState.IsValid) return Request.CreateResponse(HttpStatusCode.BadRequest, ModelState); if (id != palestrante.Id) return Request.CreateResponse(HttpStatusCode.BadRequest); var app = Construtor.PalestranteAplicacaoMongo(); var palestranteBanco = app.ListarPorId(id); if (palestranteBanco == null) return Request.CreateResponse(HttpStatusCode.BadRequest); app.Salvar(palestrante); return Request.CreateResponse(HttpStatusCode.OK); }
public void Salvar(Palestrante palestrante) { contexto.Salvar(palestrante); }