コード例 #1
0
        public async Task <HttpResponseMessage> GetGuiaInspeccion(IdModelGuiaInspeccion Id)
        {
            using (db = new DBConnection())
            {
                try
                {
                    _guiaInspeccion = await db.GuiaInspeccion.FindAsync(Id.IdGuiaInspeccion);

                    if (_guiaInspeccion == null)
                    {
                        return(new HttpResponseMessage(HttpStatusCode.NoContent));
                    }
                    else
                    {
                        return(new HttpResponseMessage(HttpStatusCode.OK)
                        {
                            Content = new StringContent(JsonConvert.SerializeObject(_guiaInspeccion), System.Text.Encoding.UTF8, "application/json")
                        });
                    }
                }
                catch (Exception ex)
                {
                    return(new HttpResponseMessage(HttpStatusCode.InternalServerError)
                    {
                        Content = new StringContent(ex.Message)
                    });
                }
            }
        }
コード例 #2
0
        public async Task <HttpResponseMessage> DeleteGuiaInspeccion(IdModelGuiaInspeccion Id)
        {
            using (db = new DBConnection())
            {
                try
                {
                    _guiaInspeccion = await db.GuiaInspeccion.FindAsync(Id.IdGuiaInspeccion);

                    if (_guiaInspeccion == null)
                    {
                        return(new HttpResponseMessage(HttpStatusCode.NoContent));
                    }
                    else
                    {
                        _guiaInspeccion.Activo_Inactivo = false;
                        db.Entry(_guiaInspeccion).State = EntityState.Modified;
                        await db.SaveChangesAsync();

                        return(new HttpResponseMessage(HttpStatusCode.OK));
                    }
                }
                catch (Exception ex)
                {
                    return(new HttpResponseMessage(HttpStatusCode.InternalServerError)
                    {
                        Content = new StringContent(ex.Message)
                    });
                }
            }
        }