示例#1
0
        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);
        }