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