private void CreateRegionVersion(IEndpointRequest request) { var regionVersion = request.Body <RegionVersionRecord>(); var websiteVersionId = request.Parameter <long?>("websiteVersionId"); var scenario = request.Parameter <string>("scenario"); var result = _dataLayer.CreateRegionVersion(request.Identity, regionVersion); if (!result.Success) { request.BadRequest(result.DebugMessage); return; } regionVersion = _dataLayer.GetRegionVersion(result.NewRecordId, (p, v) => v); if (regionVersion == null) { request.HttpStatus( HttpStatusCode.InternalServerError, "After creating the new region version it could not be found in the database"); return; } if (websiteVersionId.HasValue) { _dataLayer.AddRegionToWebsiteVersion(request.Identity, regionVersion.RecordId, websiteVersionId.Value, scenario); } request.Success(regionVersion); }
public void New(IEndpointRequest request) { var which = request.Parameter <Which>("which"); TestPerson person; switch (which) { case Which.One: person = request.Body <TestPerson>(); break; case Which.Two: person = new TestPerson { FirstName = "John", LastName = "Doe" }; break; case Which.Three: person = new TestPerson { FirstName = "Jane", LastName = "Doe" }; break; default: request.NoContent(); return; } person.FullName = person.FirstName + " " + person.LastName; request.Success(person); }
private void UpdateEnvironment(IEndpointRequest request) { var environmentId = request.Parameter <long>("id"); var changes = request.Body <List <PropertyChange> >(); if (changes.Any(c => c.PropertyName == "websiteVersionId")) { var authorization = request.OwinContext.GetFeature <IAuthorization>(); if (authorization != null) { if (!authorization.HasPermission(Permissions.ChangeEnvironmentVersion, environmentId.ToString())) { request.HttpStatus(HttpStatusCode.Forbidden, "You do not have permission '" + Permissions.ChangeEnvironmentVersion + " on environment with id=" + environmentId); } return; } } var result = _dataLayer.UpdateEnvironment(request.Identity, environmentId, changes); if (result.Success) { var environment = _dataLayer.GetEnvironment(environmentId, e => e); request.Success(environment); } else { request.BadRequest(result.DebugMessage); } }
private void CreateLayout(IEndpointRequest request) { var layout = request.Body <LayoutRecord>(); var websiteVersionId = request.Parameter <long?>("websiteVersionId"); var scenario = request.Parameter <string>("scenario"); var result = _dataLayer.CreateLayout(request.Identity, layout); if (!result.Success) { request.BadRequest(result.DebugMessage); return; } layout = _dataLayer.GetLayout(result.NewRecordId, l => l); if (layout == null) { request.HttpStatus( HttpStatusCode.InternalServerError, "After creating the new layout it could not be found in the database"); return; } if (websiteVersionId.HasValue) { _dataLayer.AddLayoutToWebsiteVersion(request.Identity, layout.RecordId, 1, websiteVersionId.Value, scenario); } request.Success(layout); }
private void CreatePage(IEndpointRequest request) { var page = request.Body <PageRecord>(); var websiteVersionId = request.Parameter <long?>("websiteVersionId"); var scenario = request.Parameter <string>("scenario"); var result = _dataLayer.CreatePage(request.Identity, page); if (!result.Success) { request.BadRequest(result.DebugMessage); return; } page = _dataLayer.GetPage(result.NewRecordId, p => p); if (page == null) { request.HttpStatus( HttpStatusCode.InternalServerError, "After creating the new page it could not be found in the database"); return; } if (websiteVersionId.HasValue) { _dataLayer.AddPageToWebsiteVersion(request.Identity, page.RecordId, 1, websiteVersionId.Value, scenario); } request.Success(page); }
private void UpdateScenario(IEndpointRequest request) { var scenario = request.Body <Scenario>(); _segmentTestingFramework.UpdateScenario(scenario); request.Success(scenario); }
private void CreateScenario(IEndpointRequest request) { var scenario = request.Body <Scenario>(); scenario.Name = _segmentTestingFramework.CreateScenario(scenario); request.Success(scenario); }
private void UpdateTest(IEndpointRequest request) { var test = request.Body <Test>(); if (test.SerializableScenarioMap != null) { test.ScenarioMap = test.SerializableScenarioMap.Select(m => new Tuple <string, string>(m.SegmentKey, m.ScenarioName)).ToArray(); } _segmentTestingFramework.UpdateTest(test); request.Success(test); }
private void UpdateRegion(IEndpointRequest request) { var regionId = request.Parameter <long>("id"); var changes = request.Body <List <PropertyChange> >(); var result = _dataLayer.UpdateRegion(request.Identity, regionId, changes); if (result.Success) { var region = _dataLayer.GetRegion(regionId, r => r); request.Success(region); } else { request.BadRequest(result.DebugMessage); } }
private void UpdateLayoutVersionComponents(IEndpointRequest request) { var layoutVersionId = request.Parameter <long>("id"); var components = request.Body <List <ElementComponentRecord> >(); var result = _dataLayer.UpdateLayoutVersionComponents(request.Identity, layoutVersionId, components); if (result.Success) { var layoutVersion = _dataLayer.GetLayoutVersion(layoutVersionId, (p, v) => v); request.Success(layoutVersion); } else { request.BadRequest(result.DebugMessage); } }
private void UpdateLayout(IEndpointRequest request) { var layoutId = request.Parameter <long>("id"); var changes = request.Body <List <PropertyChange> >(); var result = _dataLayer.UpdateLayout(request.Identity, layoutId, changes); if (result.Success) { var layout = _dataLayer.GetLayout(layoutId, l => l); request.Success(layout); } else { request.BadRequest(result.DebugMessage); } }
private void UpdatePageVersionZones(IEndpointRequest request) { var pageVersionId = request.Parameter <long>("id"); var zones = request.Body <List <LayoutZoneRecord> >(); var result = _dataLayer.UpdatePageVersionLayoutZones(request.Identity, pageVersionId, zones); if (result.Success) { var pageVersion = _dataLayer.GetPageVersion(pageVersionId, (p, v) => v); request.Success(pageVersion); } else { request.BadRequest(result.DebugMessage); } }
private void UpdatePage(IEndpointRequest request) { var pageId = request.Parameter <long>("id"); var changes = request.Body <List <PropertyChange> >(); var result = _dataLayer.UpdatePage(request.Identity, pageId, changes); if (result.Success) { var page = _dataLayer.GetPage(pageId, p => p); request.Success(page); } else { request.BadRequest(result.DebugMessage); } }
private void UpdateComponentVersion(IEndpointRequest request) { var componentVersionId = request.Parameter <long>("id"); var changes = request.Body <List <PropertyChange> >(); var result = _dataLayer.UpdateComponentVersion(request.Identity, componentVersionId, changes); if (result.Success) { var componentVersion = _dataLayer.GetComponentVersion(componentVersionId, (p, v) => v); request.Success(componentVersion); } else { request.BadRequest(result.DebugMessage); } }
private void CreateEnvironment(IEndpointRequest request) { var environment = request.Body <EnvironmentRecord>(); var result = _dataLayer.CreateEnvironment(request.Identity, environment); if (!result.Success) { request.BadRequest(result.DebugMessage); return; } environment = _dataLayer.GetEnvironment(result.NewRecordId, e => e); if (environment == null) { request.HttpStatus( HttpStatusCode.InternalServerError, "After creating the new environment it could not be found in the database"); return; } request.Success(environment); }
private void CreateWebsiteVersion(IEndpointRequest request) { var websiteVersion = request.Body <WebsiteVersionRecord>(); var result = _dataLayer.CreateWebsiteVersion(request.Identity, websiteVersion); if (!result.Success) { request.BadRequest(result.DebugMessage); return; } websiteVersion = _dataLayer.GetWebsiteVersion(result.NewRecordId, e => e); if (websiteVersion == null) { request.HttpStatus( HttpStatusCode.InternalServerError, "After creating the new website version it could not be found in the database"); return; } request.Success(websiteVersion); }