Example #1
0
        public HttpResponseMessage PatchGrupo(Grupo grupo)
        {
            if (grupo == null)
                return Request.CreateResponse(HttpStatusCode.BadRequest);

            try
            {
                db.Entry<Grupo>(grupo).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                var result = grupo;
                return Request.CreateResponse(HttpStatusCode.BadRequest, result);
            }
            catch (Exception)
            {
                return Request.CreateResponse(HttpStatusCode.InternalServerError, "Falha ao alterar grupo.");
            }
        }
Example #2
0
        public HttpResponseMessage PostGrupos(Grupo grupo)
        {
            if (grupo == null)
                return Request.CreateResponse(HttpStatusCode.BadRequest);

            try
            {
                db.Grupos.Add(grupo);
                db.SaveChanges();

                var result = grupo;
                return Request.CreateResponse(HttpStatusCode.Created, result);
            }
            catch (Exception)
            {
                return Request.CreateResponse(HttpStatusCode.InternalServerError,"Falha ao incluir grupo.");
            }            
        }