コード例 #1
0
        public IActionResult UploadTemplate(string projectid, [FromBody] CompileResourceRequest req)
        {
            try
            {
                if (req == null)
                {
                    return(BadRequest("Request object can not be null"));
                }

                req.ProjectId = projectid;

                var projectDetailsRequestModel = new GetProjectDetailsRequestModel
                {
                    ProjectId        = req.ProjectId,
                    ExcludeResources = false,
                    UserEmail        = req.UserEmail
                };

                var compileResult = CompilerHelper.CompileProjectResource(req);

                var compilerService   = new CompilerService();
                var updatePageRequest = new CreateOrUpdateResourceRequestModel
                {
                    Errors        = null,
                    FileContent   = req.FileContent,
                    SourcePath    = req.SourcePath.Trim(),
                    ClassName     = req.ClassName,
                    ProjectId     = req.ProjectId,
                    UserEmail     = req.UserEmail,
                    UrlPattern    = req.UrlPattern,
                    IsStatic      = req.IsStatic,
                    IsDefault     = req.IsDefault,
                    PageType      = req.PageType,
                    KObject       = req.KObject,
                    ResourceType  = null,
                    Configuration = !string.IsNullOrEmpty(req.Configuration) ? JsonConvert.DeserializeObject <Dictionary <string, object> >(req.Configuration) : null,
                };

                var validationResult = updatePageRequest.Validate();
                if (validationResult.Any())
                {
                    return(BadRequest(validationResult));
                }

                if (MongoConnector.CreateOrUpdateResource(updatePageRequest))
                {
                    return(Ok(compileResult));
                }

                return(BadRequest());
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }
コード例 #2
0
        public IActionResult UpdatePageDetails(string projectid, [FromBody] CompileResourceRequest req)
        {
            try
            {
                if (req == null)
                {
                    return(BadRequest("Request object can not be null"));
                }

                req.ProjectId = projectid;
                req.IsPublish = false;

                var compileResult = CompilerHelper.CompileProjectResource(req);

                var compilerService   = new CompilerService();
                var updatePageRequest = new CreateOrUpdateResourceRequestModel
                {
                    Errors       = null,
                    FileContent  = req.FileContent,
                    SourcePath   = req.SourcePath.Trim(),
                    ClassName    = req.ClassName,
                    ProjectId    = req.ProjectId,
                    UserEmail    = req.UserEmail,
                    UrlPattern   = req.UrlPattern,
                    IsStatic     = req.IsStatic,
                    IsDefault    = req.IsDefault,
                    PageType     = req.PageType,
                    KObject      = req.KObject,
                    ResourceType = null
                };

                var validationResult = updatePageRequest.Validate();
                if (validationResult.Any())
                {
                    return(BadRequest(validationResult));
                }
                if (MongoConnector.CreateOrUpdateResource(updatePageRequest))
                {
                    return(Ok(compileResult));
                }
                return(BadRequest());
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }
コード例 #3
0
        public IActionResult CompileKitsuneResource(string projectid, [FromQuery] string resourcename, [FromQuery] string user, [FromBody] CompileResourceRequest req)
        {
            try
            {
                req.UserEmail  = user;
                req.ProjectId  = projectid;
                req.SourcePath = resourcename;

                //Compile project dosent required partial pages
                var compileResult = CompilerHelper.CompileProjectResource(req);
                return(Ok(compileResult));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }