Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
 public void Salvar(Sala sala)
 {
     contexto.Salvar(sala);
 }