Exemplo n.º 1
0
        public async Task <HttpResponseMessage> GetRefaccion(IdModelRefaccion id)
        {
            try
            {
                _refaccion = await db.Refaccion.FindAsync(id.IdReFaccion);

                if (_refaccion == null)
                {
                    return(new HttpResponseMessage(HttpStatusCode.NoContent));
                }
                else
                {
                    return(new HttpResponseMessage(HttpStatusCode.OK)
                    {
                        Content = new StringContent(JsonConvert.SerializeObject(_refaccion), System.Text.Encoding.UTF8, "application/json")
                    });
                }
            }
            catch (Exception ex)
            {
                return(new HttpResponseMessage(HttpStatusCode.InternalServerError)
                {
                    Content = new StringContent(ex.Message)
                });
            }
        }
Exemplo n.º 2
0
        public async Task <HttpResponseMessage> DeleteRefaccion(IdModelRefaccion id)
        {
            try
            {
                _refaccion = await db.Refaccion.FindAsync(id.IdReFaccion);

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

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