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

            if (id != habitos_toxicos.idPaciente)
            {
                return(BadRequest());
            }

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

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

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

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

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

            db.habitos_toxicos.Add(habitos_toxicos);
            await db.SaveChangesAsync();

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

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

            db.habitos_toxicos.Remove(habitos_toxicos);
            await db.SaveChangesAsync();

            return(Ok(habitos_toxicos));
        }