Example #1
0
        public async Task <HttpResponseMessage> GetCatalogoEvento(IdModelCatalogoEventos Id)
        {
            try
            {
                var entry = await db.CatalogoEvento.FindAsync(Id.IdCatalogoEvento);

                if (entry == null)
                {
                    return(new HttpResponseMessage(HttpStatusCode.NoContent));
                }
                else
                {
                    _catalogoEvento = new EventoService()
                    {
                        IdCatalogoEvento  = entry.IdCatalogoEvento,
                        IdArea            = entry.IdArea,
                        IdTipoEvento      = entry.IdTipoEvento,
                        CodigoEvento      = entry.CodigoEvento,
                        DescripcionEvento = entry.DescripcionEvento
                    };
                    return(new HttpResponseMessage(HttpStatusCode.OK)
                    {
                        Content = new StringContent(JsonConvert.SerializeObject(_catalogoEvento), System.Text.Encoding.UTF8, "application/json")
                    });
                }
            }
            catch (Exception ex)
            {
                return(new HttpResponseMessage(HttpStatusCode.InternalServerError)
                {
                    Content = new StringContent(ex.Message)
                });
            }
        }
Example #2
0
        public async Task <HttpResponseMessage> DeleteCatalogoEvento(IdModelCatalogoEventos Id)
        {
            try
            {
                var entry = await db.CatalogoEvento.FindAsync(Id.IdCatalogoEvento);

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

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