public HttpResponseMessage Get([FromUri] int 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; } Entidad _entidad = entidadRepository.GetById(include, (p => p.Id == Id)); if (cultura != Localizacion.CulturaPorDefecto) { Entidad_Idioma _entidadIdioma = entidad_IdiomaRepository.GetMany(p => p.IdRegistro == Id && p.Cultura == cultura).FirstOrDefault(); // Campos multiidioma if (_entidadIdioma != null) { _entidad.Nombre = _entidadIdioma.Nombre; } } if (_entidad == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } return(Request.CreateResponse <Entidad>(HttpStatusCode.OK, _entidad, 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 <Entidad_Idioma> >(HttpStatusCode.OK, entidad_idiomaRepository.GetMany(include, (p => id.Contains(p.Id))), formatter)); } catch (Exception _excepcion) { log.Error(_excepcion); return(Request.CreateResponse(HttpStatusCode.InternalServerError, _excepcion)); } }