Exemplo n.º 1
0
        public IHttpActionResult PutP1_Group(int id, P1_Group p1_Group)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != p1_Group.U_id)
            {
                return(BadRequest());
            }

            db.Entry(p1_Group).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!P1_GroupExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.OK));
        }
Exemplo n.º 2
0
        public IHttpActionResult GetP1_Group(int id)
        {
            P1_Group p1_Group = db.P1_Group.Find(id);

            if (p1_Group == null)
            {
                return(NotFound());
            }

            return(Ok(p1_Group));
        }
Exemplo n.º 3
0
        public IHttpActionResult PostP1_Group(P1_Group p1_Group)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.P1_Group.Add(p1_Group);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = p1_Group.G_id }, p1_Group));
        }
Exemplo n.º 4
0
        public IHttpActionResult DeleteP1_Group(int id)
        {
            P1_Group p1_Group = db.P1_Group.Find(id);

            if (p1_Group == null)
            {
                return(NotFound());
            }

            db.P1_Group.Remove(p1_Group);
            db.SaveChanges();

            return(Ok(p1_Group));
        }