public HttpResponseMessage Get([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; } SolicitudContacto solicitudcontacto = solicitudcontactoRepository.GetById(include, (p => p.Id == Id)); if (solicitudcontacto == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } return(Request.CreateResponse <SolicitudContacto>(HttpStatusCode.OK, solicitudcontacto, formatter)); } catch (Exception _excepcion) { log.Error(_excepcion); return(Request.CreateResponse(HttpStatusCode.InternalServerError, _excepcion)); } }
public ICommandResult Execute(CreateOrUpdateSolicitudContactoCommand command) { SolicitudContacto _SolicitudContacto = AutoMapper.Mapper.Map <CreateOrUpdateSolicitudContactoCommand, SolicitudContacto>(command); if (command.Id == 0) { SolicitudContactoRepository.Add(_SolicitudContacto); } else { SolicitudContactoRepository.Update(_SolicitudContacto); } unitOfWork.Commit(); AutoMapper.Mapper.Map <SolicitudContacto, CreateOrUpdateSolicitudContactoCommand>(_SolicitudContacto, command); return(new CommandResult(true)); }