Beispiel #1
0
        public async Task <IHttpActionResult> Putobrasocial(int id, obrasocial obrasocial)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != obrasocial.Persona_id)
            {
                return(BadRequest());
            }

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

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!obrasocialExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #2
0
        public async Task <IHttpActionResult> Getobrasocial(int id)
        {
            obrasocial obrasocial = await db.obrasocials.FindAsync(id);

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

            return(Ok(obrasocial));
        }
Beispiel #3
0
        public async Task <IHttpActionResult> Postobrasocial(obrasocial obrasocial)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.obrasocials.Add(obrasocial);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = obrasocial.Persona_id }, obrasocial));
        }
Beispiel #4
0
        public async Task <IHttpActionResult> Deleteobrasocial(int id)
        {
            obrasocial obrasocial = await db.obrasocials.FindAsync(id);

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

            db.obrasocials.Remove(obrasocial);
            await db.SaveChangesAsync();

            return(Ok(obrasocial));
        }