Exemplo n.º 1
0
        public HttpResponseMessage Get([FromUri] short Id, [FromUri] string cultura, [FromUri] string[] include, [FromUri] bool indent = false)
        {
            try {
                var formatter = new MaxDepthJsonMediaTypeFormatter()
                {
                    Indent = indent
                };
                if (include.Length > 0)
                {
                    formatter.SerializerSettings.MaxDepth = 100;                     //include.Max<string>(s => s.Split('.').Length * 5);
                    formatter.SerializerSettings.PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.Objects;
                }
                else
                {
                    formatter.SerializerSettings.MaxDepth = 1;
                }
                CategoriaCalendario _categoriacalendario = categoriacalendarioRepository.GetById(include, (p => p.Id == Id));
                if (cultura != Localizacion.CulturaPorDefecto)
                {
                    CategoriaCalendario_Idioma _categoriacalendarioIdioma = categoriacalendario_IdiomaRepository.GetMany(p => p.IdRegistro == Id && p.Cultura == cultura).FirstOrDefault();

                    // Campos multiidioma
                    if (_categoriacalendarioIdioma != null)
                    {
                        _categoriacalendario.Nombre = _categoriacalendarioIdioma.Nombre;
                    }
                }

                if (_categoriacalendario == null)
                {
                    throw new HttpResponseException(HttpStatusCode.NotFound);
                }
                return(Request.CreateResponse <CategoriaCalendario>(HttpStatusCode.OK, _categoriacalendario, formatter));
            } catch (Exception _excepcion) {
                log.Error(_excepcion);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, _excepcion));
            }
        }
 public HttpResponseMessage GetList([FromUri] int[] id, [FromUri] string[] include, [FromUri] bool indent = false)
 {
     try {
         var formatter = new MaxDepthJsonMediaTypeFormatter()
         {
             Indent = indent
         };
         if (include.Length > 0)
         {
             formatter.SerializerSettings.MaxDepth = 100;                     //include.Max<string>(s => s.Split('.').Length * 5);
             formatter.SerializerSettings.PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.Objects;
         }
         else
         {
             formatter.SerializerSettings.MaxDepth = 1;
         }
         return(Request.CreateResponse <IEnumerable <CategoriaCalendario_Idioma> >(HttpStatusCode.OK, categoriacalendario_idiomaRepository.GetMany(include, (p => id.Contains(p.Id))), formatter));
     } catch (Exception _excepcion) {
         log.Error(_excepcion);
         return(Request.CreateResponse(HttpStatusCode.InternalServerError, _excepcion));
     }
 }