public Response Post(SocketEndpointHomeModel theModel) { if (theModel != null) { string EndpointGuid = string.IsNullOrEmpty(theModel.Guid) ? Guid.NewGuid().ToString() : theModel.Guid; Core.Instance.Update(new SocketEndpointProperties[] { new SocketEndpointProperties { Guid = EndpointGuid, LoggingLevel = theModel.LoggingLevel, } }); return(new Response { StatusCode = System.Net.HttpStatusCode.Moved, Location = new Uri(Context.Referrer, Context.Referrer.AbsolutePath + "?id=" + EndpointGuid) }); } return(new Response { StatusCode = System.Net.HttpStatusCode.Moved, Location = Context.Referrer }); }
public Response Get(string id) { SocketEndpointComponent SocketEndpoint = null; if (!string.IsNullOrEmpty(id)) { SocketEndpoint = Core.Instance.SocketEndpoints.FirstOrDefault(t => t.Guid == id); if (SocketEndpoint == null) { return(new Response { StatusCode = HttpStatusCode.NotFound, Template = Templates.SettingsNotFound }); } } SocketEndpointHomeModel model; Subscription[] Subscriptions = null; if (SocketEndpoint != null) { model = new SocketEndpointHomeModel { Guid = SocketEndpoint.Guid, ConnectedClients = SocketEndpoint.ConnectedClients(), LoggingLevel = SocketEndpoint.LoggingLevel, TraceLog = SocketEndpoint.TraceLog, }; Subscriptions = new Subscription[] { new Subscription { Id = SocketEndpoint.LogEventId } }; } else { model = new SocketEndpointHomeModel { Guid = string.Empty, ConnectedClients = new string[0], LoggingLevel = 0, TraceLog = string.Empty, }; } return(new Response { Model = model, Template = Templates.SettingsSocketEndpointHome, Subscriptions = Subscriptions }); }