コード例 #1
0
        public object MoveLayout(MoveLayoutRequest request)
        {
            // Variables.
            var result   = default(object);
            var rootId   = CoreConstants.System.Root.ToInvariantString();
            var parentId = GuidHelper.GetGuid(request.NewParentId);


            // Catch all errors.
            try
            {
                // Parse the layout ID.
                var layoutId = GuidHelper.GetGuid(request.LayoutId);


                // Get the ID path.
                var path = Entities.Retrieve(parentId).Path
                           .Concat(new[] { layoutId }).ToArray();


                // Get layout and update path.
                var layout = Persistence.Retrieve(layoutId);
                layout.Path = path;


                // Persist layout.
                Persistence.Persist(layout);


                // Variables.
                var fullPath = new[] { rootId }
                .Concat(path.Select(x => GuidHelper.GetString(x)))
                .ToArray();


                // Success.
                result = new
                {
                    Success = true,
                    Id      = GuidHelper.GetString(layoutId),
                    Path    = fullPath
                };
            }
            catch (Exception ex)
            {
                // Error.
                Logger.Error <LayoutsController>(ex, MoveLayoutError);
                result = new
                {
                    Success = false,
                    Reason  = UnhandledError
                };
            }


            // Return result.
            return(result);
        }
コード例 #2
0
        public object MoveLayout(MoveLayoutRequest request)
        {
            // Variables.
            var result = default(object);
            var rootId = CoreConstants.System.Root.ToInvariantString();
            var parentId = GuidHelper.GetGuid(request.NewParentId);

            // Catch all errors.
            try
            {

                // Parse the layout ID.
                var layoutId = GuidHelper.GetGuid(request.LayoutId);

                // Get the ID path.
                var path = Entities.Retrieve(parentId).Path
                    .Concat(new[] { layoutId }).ToArray();

                // Get layout and update path.
                var layout = Persistence.Retrieve(layoutId);
                layout.Path = path;

                // Persist layout.
                Persistence.Persist(layout);

                // Variables.
                var fullPath = new[] { rootId }
                    .Concat(path.Select(x => GuidHelper.GetString(x)))
                    .ToArray();

                // Success.
                result = new
                {
                    Success = true,
                    Id = GuidHelper.GetString(layoutId),
                    Path = fullPath
                };

            }
            catch (Exception ex)
            {

                // Error.
                LogHelper.Error<LayoutsController>(MoveLayoutError, ex);
                result = new
                {
                    Success = false,
                    Reason = UnhandledError
                };

            }

            // Return result.
            return result;
        }