Пример #1
0
        public IActionResult UpdateWebsiteData([FromRoute] string schemaname, [FromBody] UpdateWebsiteDataRequestModel requestModel)
        {
            ///TODO : Chheck that mongodb driver support long for skip and limit
            // string userid = Request.Headers.Authorization.ToString();
            // command.UserId = userid;
            try
            {
                var userId = AuthHelper.AuthorizeRequest(Request);
                if (string.IsNullOrEmpty(userId))
                {
                    return(new CommonActionResult(CommonAPIResponse.UnAuthorized()));
                }
                else
                {
                    requestModel.UserId = userId;
                }

                requestModel.SchemaName = schemaname;
                // requestModel.SchemaName = schemaname.ToUpper();
                var validationResult = requestModel.Validate();
                if (validationResult.Any())
                {
                    return(BadRequest(validationResult));
                }

                return(new CommonActionResult(MongoConnector.UpdateWebsiteData(requestModel)));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }
        public IActionResult CheckWebsiteTagAvailability(string websitetag, [FromQuery] string clientId, [FromQuery] string projectId)
        {
            var developerId = AuthHelper.AuthorizeRequest(Request);

            if (string.IsNullOrEmpty(developerId))
            {
                return(new CommonActionResult(CommonAPIResponse.UnAuthorized()));
            }

            try
            {
                try
                {
                    if (String.IsNullOrEmpty(clientId) && !String.IsNullOrEmpty(projectId))
                    {
                        clientId = MongoConnector.GetClientIdFromProjectId(projectId);
                    }
                }
                catch { }

                return(new CommonActionResult(MongoConnector.CheckWebsiteTagAvailability(websitetag, clientId)));
            }
            catch (Exception ex)
            {
                return(new CommonActionResult(CommonAPIResponse.InternalServerError(ex)));
            }
        }
        public IActionResult ChangeKitsuneWebsiteUserPassword(string WebsiteId, string WebsiteUserId, [FromBody] UpdateWebsiteUserPasswordRequestModel requestModel)
        {
            try
            {
                requestModel.WebsiteId     = WebsiteId;
                requestModel.WebsiteUserId = WebsiteUserId;
                var developerId = AuthHelper.AuthorizeRequest(Request);
                if (string.IsNullOrEmpty(developerId))
                {
                    return(new CommonActionResult(CommonAPIResponse.UnAuthorized()));
                }
                requestModel.DeveloperId = developerId;
                var validationResult = requestModel.Validate();
                if (validationResult.Any())
                {
                    return(new CommonActionResult(CommonAPIResponse.BadRequest(validationResult)));
                }

                return(new CommonActionResult(MongoConnector.ChangeWebsiteUserPassword(requestModel)));
            }
            catch (Exception ex)
            {
                return(new CommonActionResult(CommonAPIResponse.InternalServerError(ex)));
            }
        }
Пример #4
0
        public IActionResult GetWebsiteDataByType([FromRoute] string schemaname, [FromQuery] string website, [FromQuery] string className)
        {
            try
            {
                var requestModel = new GetWebsiteDataByTypeRequestModel
                {
                    SchemaName = schemaname,
                    WebsiteId  = website,
                    ClassName  = className,
                };

                var userId = AuthHelper.AuthorizeRequest(Request);
                if (string.IsNullOrEmpty(userId))
                {
                    return(new CommonActionResult(CommonAPIResponse.UnAuthorized()));
                }
                else
                {
                    requestModel.UserId = userId;
                }

                var validationResult = requestModel.Validate();
                if (validationResult.Any())
                {
                    return(BadRequest(validationResult));
                }
                return(Ok(MongoConnector.GetWebsiteDataByType(requestModel)));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }
Пример #5
0
        public IActionResult AddOrUpdateWebsite([FromRoute] string schemaname, [FromBody] AddOrUpdateWebsiteRequestModel requestModel, [FromRoute] string clientid = null, [FromRoute] string schemaid = null)
        {
            try
            {
                var userId = AuthHelper.AuthorizeRequest(Request);

                if (string.IsNullOrEmpty(userId) && (string.IsNullOrEmpty(clientid) || BasePluginConfigGenerator.GetBasePlugin(clientid).GetClientId() != clientid.Trim().ToUpper()))
                {
                    return(new CommonActionResult(CommonAPIResponse.UnAuthorized()));
                }

                requestModel.UserId     = userId;
                requestModel.SchemaId   = schemaid;
                requestModel.SchemaName = schemaname;

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

                return(Ok(MongoConnector.AddDataForWebsite(requestModel)));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }
Пример #6
0
        public IActionResult DeleteWebsiteData([FromRoute] string schemaname, [FromBody] DeleteDataObjectRequestModel requestModel)
        {
            try
            {
                var userId = AuthHelper.AuthorizeRequest(Request);
                if (string.IsNullOrEmpty(userId))
                {
                    return(new CommonActionResult(CommonAPIResponse.UnAuthorized()));
                }
                else
                {
                    requestModel.UserId = userId;
                }

                requestModel.SchemaName = schemaname;
                // requestModel.SchemaName = schemaname.ToUpper();
                var validationResult = requestModel.Validate();
                if (validationResult.Any())
                {
                    return(BadRequest(validationResult));
                }

                return(Ok(MongoConnector.DeleteObject(requestModel)));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }
Пример #7
0
        public IActionResult DeleteFile(string websiteid, [FromQuery] string assetFileName)
        {
            if (string.IsNullOrEmpty(websiteid))
            {
                return(BadRequest("Website id can not be empty"));
            }

            if (string.IsNullOrEmpty(assetFileName))
            {
                return(BadRequest("File name can not be empty"));
            }

            var userId = AuthHelper.AuthorizeRequest(Request);

            if (string.IsNullOrEmpty(userId))
            {
                return(new CommonActionResult(CommonAPIResponse.UnAuthorized()));
            }
            //TODO : Validate the userid with websiteid


            var bucketName = "kitsune-website-files-cdn";

            assetFileName = assetFileName.Trim();
            var result = AmazonS3Helper.DeleteAsset($"v1/{websiteid}/{assetFileName}", bucketName);

            if (result)
            {
                return(Ok());
            }

            return(BadRequest("Invalid website id"));
        }
Пример #8
0
        public IActionResult VersionLanguageSchema(VersionLanguageSchema requestModel)
        {
            try
            {
                var userId = AuthHelper.AuthorizeRequest(Request);
                if (string.IsNullOrEmpty(userId))
                {
                    return(new CommonActionResult(CommonAPIResponse.UnAuthorized()));
                }
                else
                {
                    requestModel.UserId = userId;
                }

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

                return(Ok(MongoConnector.VersionLanguageSchema(requestModel)));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }
        public IActionResult DeactivateWebsites([FromBody] DeActivateWebsitesRequestModel deactivateRequestModel)
        {
            try
            {
                var userId = AuthHelper.AuthorizeRequest(Request);
                if (string.IsNullOrEmpty(userId))
                {
                    return(new CommonActionResult(CommonAPIResponse.UnAuthorized()));
                }
                DeActivateWebsitesRequestModel requestModel = new DeActivateWebsitesRequestModel
                {
                    WebsiteIds = deactivateRequestModel.WebsiteIds,
                    UserId     = userId
                };
                var validationResult = requestModel.Validate();
                if (validationResult.Any())
                {
                    return(new CommonActionResult(CommonAPIResponse.BadRequest(validationResult)));
                }

                return(new CommonActionResult(MongoConnector.DeactivateWebsites(requestModel)));
            }
            catch (Exception ex)
            {
                return(new CommonActionResult(CommonAPIResponse.InternalServerError(ex)));
            }
        }
Пример #10
0
        public IActionResult MapWebsiteToWebAction([FromBody] MapSchemaToProjectRequestModel requestModel)
        {
            try
            {
                var userId = AuthHelper.AuthorizeRequest(Request);
                if (string.IsNullOrEmpty(userId))
                {
                    return(new CommonActionResult(CommonAPIResponse.UnAuthorized()));
                }
                else
                {
                    requestModel.UserId = userId;
                }

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

                return(Ok(MongoConnector.MapSchemaToProject(requestModel)));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }
Пример #11
0
        public IActionResult GetIntellisense([FromRoute] string projectid)
        {
            try
            {
                var requestModel = new GetIntellisenseRequestModel
                {
                    ProjectId = projectid
                };

                var userId = AuthHelper.AuthorizeRequest(Request);
                if (string.IsNullOrEmpty(userId))
                {
                    return(new CommonActionResult(CommonAPIResponse.UnAuthorized()));
                }
                else
                {
                    requestModel.UserId = userId;
                }

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

                return(Ok(MongoConnector.GetIntellisense(requestModel)));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }
Пример #12
0
        public IActionResult GetLanguageEntityForTypeBySegment([FromRoute] string languageid, [FromQuery] string className, [FromQuery] string websiteId)
        {
            try
            {
                string UserId = AuthHelper.AuthorizeRequest(Request);

                var requestModel = new GetSimilarPropertiesInLanguageEntityRequestModel
                {
                    EntityId  = languageid,
                    ClassName = className,
                    WebsiteId = websiteId
                };
                var validationResult = requestModel.Validate();
                if (validationResult.Any())
                {
                    return(BadRequest(validationResult));
                }

                return(Ok(MongoConnector.GetSimilarPropertyPathSegments(requestModel)));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }
        public IActionResult GenerateKAdminLoginToken([FromQuery] string websiteId, [FromQuery] string source = "IDE")
        {
            try
            {
                var userId = AuthHelper.AuthorizeRequest(Request);
                if (string.IsNullOrEmpty(userId))
                {
                    return(new CommonActionResult(CommonAPIResponse.UnAuthorized()));
                }
                GenerateKAdminLoginTokenRequestModel requestModel = new GenerateKAdminLoginTokenRequestModel
                {
                    WebsiteId  = websiteId,
                    UserId     = userId,
                    ExpiryTime = source == "IDE" ? 2 : 30,
                    Source     = source
                };

                var validationResult = requestModel.Validate();
                if (validationResult.Any())
                {
                    return(new CommonActionResult(CommonAPIResponse.BadRequest(validationResult)));
                }

                return(new CommonActionResult(MongoConnector.GenerateKAdminLoginToken(requestModel)));
            }
            catch (Exception ex)
            {
                return(new CommonActionResult(CommonAPIResponse.InternalServerError(ex)));
            }
        }
Пример #14
0
 public IActionResult GetWebsiteDataByPropertyPath([FromRoute] string schemaid, [FromBody] GetWebsiteDataByPropertyPathV2 requestModel, [FromRoute] string clientid = null)
 {
     try
     {
         var userId = AuthHelper.AuthorizeRequest(Request);
         if (string.IsNullOrEmpty(userId) && (string.IsNullOrEmpty(clientid) || BasePluginConfigGenerator.GetBasePlugin(clientid).GetClientId() != clientid.Trim().ToUpper()))
         {
             return(new CommonActionResult(CommonAPIResponse.UnAuthorized()));
         }
         requestModel.SchemaId = schemaid;
         var validationResult = requestModel.Validate();
         if (validationResult.Any())
         {
             return(BadRequest(validationResult));
         }
         var result        = new List <GetWebsiteDataByPropertyResponseModel>();
         var segmentRequet = new GetWebsiteDataByPropertyPath()
         {
             SchemaId = requestModel.SchemaId, UserEmail = requestModel.UserEmail, WebsiteId = requestModel.WebsiteId
         };
         foreach (var segments in requestModel.BulkPropertySegments)
         {
             segmentRequet.PropertySegments = segments;
             result.Add(MongoConnector.GetWebsiteDataByPropertyPath(segmentRequet));
         }
         return(new CommonActionResult(CommonAPIResponse.OK(result)));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex));
     }
 }
 public IActionResult GetKitsuneWebsiteUser(string WebsiteId, string WebsiteUserId)
 {
     try
     {
         var developerId = AuthHelper.AuthorizeRequest(Request);
         if (string.IsNullOrEmpty(developerId))
         {
             return(new CommonActionResult(CommonAPIResponse.UnAuthorized()));
         }
         return(new CommonActionResult(MongoConnector.GetWebsiteUserDetails(WebsiteId, WebsiteUserId)));
     }
     catch (Exception ex)
     {
         return(new CommonActionResult(CommonAPIResponse.InternalServerError(ex)));
     }
 }
 public IActionResult GetKitsuneWebsiteDetails(string WebsiteId, [FromQuery] string clientid = null)
 {
     try
     {
         var developerId = AuthHelper.AuthorizeRequest(Request);
         if (string.IsNullOrEmpty(developerId) && (string.IsNullOrEmpty(clientid) || BasePluginConfigGenerator.GetBasePlugin(clientid).GetClientId() != clientid.Trim().ToUpper()))
         {
             return(new CommonActionResult(CommonAPIResponse.UnAuthorized()));
         }
         return(new CommonActionResult(MongoConnector.GetKitsuneWebsiteDetails(WebsiteId)));
     }
     catch (Exception ex)
     {
         return(new CommonActionResult(CommonAPIResponse.InternalServerError(ex)));
     }
 }
 public IActionResult IsCallTrackerEnabled([FromQuery] string WebsiteId)
 {
     try
     {
         var developerId = AuthHelper.AuthorizeRequest(Request);
         if (string.IsNullOrEmpty(developerId))
         {
             return(new CommonActionResult(CommonAPIResponse.UnAuthorized()));
         }
         return(new CommonActionResult(MongoConnector.IsCallTrackerEnabledForWebsite(WebsiteId)));
     }
     catch (Exception ex)
     {
         return(new CommonActionResult(CommonAPIResponse.InternalServerError(ex)));
     }
 }
        public IActionResult CheckDomainAvailability([FromQuery] string domainName)
        {
            var developerId = AuthHelper.AuthorizeRequest(Request);

            if (string.IsNullOrEmpty(developerId))
            {
                return(new CommonActionResult(CommonAPIResponse.UnAuthorized()));
            }
            try
            {
                return(new CommonActionResult(MongoConnector.CheckKitsuneDomainAvailability(domainName)));
            }
            catch (Exception ex)
            {
                return(new CommonActionResult(CommonAPIResponse.InternalServerError(ex)));
            }
        }
        public IActionResult GetKitsuneWebsiteListForProject([FromQuery] string projectId, int limit = 100, int skip = 0, bool includeusers = false)
        {
            var developerId = AuthHelper.AuthorizeRequest(Request);

            if (string.IsNullOrEmpty(developerId))
            {
                return(new CommonActionResult(CommonAPIResponse.UnAuthorized()));
            }
            try
            {
                return(new CommonActionResult(MongoConnector.GetKitsuneWebsiteListForProject(developerId, projectId, limit, skip, includeusers)));
            }
            catch (Exception ex)
            {
                return(new CommonActionResult(CommonAPIResponse.InternalServerError(ex)));
            }
        }
        public IActionResult GetLiveWebsites([FromQuery] int limit = 100, [FromQuery] int skip = 0)
        {
            var developerId = AuthHelper.AuthorizeRequest(Request);

            if (string.IsNullOrEmpty(developerId))
            {
                return(new CommonActionResult(CommonAPIResponse.UnAuthorized()));
            }
            try
            {
                return(new CommonActionResult(MongoConnector.GetKitsuneLiveWebsites(developerId, limit, skip)));
            }
            catch (Exception ex)
            {
                return(new CommonActionResult(CommonAPIResponse.InternalServerError(ex)));
            }
        }
        public IActionResult GetAllLiveWebsites([FromQuery] int limit = 100, [FromQuery] int skip = 0)
        {
            var authId = AuthHelper.AuthorizeRequest(Request);

            if (String.IsNullOrEmpty(authId) || String.Compare(authId, "4C627432590419E9CF79252291B6A3AE25D7E2FF13347C6ACD1587C47C6ACDD") != 0)
            {
                return(new CommonActionResult(CommonAPIResponse.UnAuthorized()));
            }

            try
            {
                return(new CommonActionResult(MongoConnector.GetAllKitsuneLiveWebsites(limit, skip)));
            }
            catch (Exception ex)
            {
                return(new CommonActionResult(CommonAPIResponse.InternalServerError(ex)));
            }
        }
        public IActionResult CreateNewWebsite([FromBody] CreateNewWebsiteRequestModel requestModel, [FromQuery] string clientid = null)
        {
            try
            {
                var authId = AuthHelper.AuthorizeRequest(Request);

                try
                {
                    if (String.IsNullOrEmpty(clientid) && !String.IsNullOrEmpty(requestModel.DeveloperId))
                    {
                        requestModel.ClientId = MongoConnector.GetClientIdFromProjectId(requestModel.ProjectId);
                    }
                }
                catch { }

                requestModel.ClientId = BasePluginConfigGenerator.GetBasePlugin(clientid).GetClientId();
                if (string.IsNullOrEmpty(clientid) || requestModel.ClientId != clientid.Trim().ToUpper())
                {
                    return(new CommonActionResult(CommonAPIResponse.UnAuthorized()));
                }

                requestModel.ActivateWebsite = false;

                if (requestModel.ClientId == Constants.ClientIdConstants.NowFloatsClientId)
                {
                    requestModel.ActivateWebsite = true;
                }


                requestModel.DeveloperId = MongoConnector.GetUserIdFromProjectId(requestModel.ProjectId);

                var validationResult = requestModel.Validate();
                if (validationResult.Any())
                {
                    return(new CommonActionResult(CommonAPIResponse.BadRequest(validationResult)));
                }

                return(new CommonActionResult(MongoConnector.CreateNewWebsite(requestModel)));
            }
            catch (Exception ex)
            {
                return(new CommonActionResult(CommonAPIResponse.InternalServerError(ex)));
            }
        }
Пример #23
0
        public IActionResult SearchData(string schemaname, string searchtext, [FromBody] SearchDataRequestModel requestModel, [FromQuery] int skip = 0, [FromQuery] int limit = 100)
        {
            try
            {
                var userId = AuthHelper.AuthorizeRequest(Request);
                if (string.IsNullOrEmpty(userId))
                {
                    return(new CommonActionResult(CommonAPIResponse.UnAuthorized()));
                }

                requestModel.UserId = userId;

                if (requestModel == null)
                {
                    return(new CommonActionResult(CommonAPIResponse.BadRequest(new System.ComponentModel.DataAnnotations.ValidationResult("Invalid request body"))));
                }
                if (string.IsNullOrEmpty(schemaname))
                {
                    return(new CommonActionResult(CommonAPIResponse.BadRequest(new System.ComponentModel.DataAnnotations.ValidationResult("Schema name can not be empty"))));
                }

                if (string.IsNullOrEmpty(searchtext))
                {
                    return(new CommonActionResult(CommonAPIResponse.BadRequest(new System.ComponentModel.DataAnnotations.ValidationResult("Search text can not be empty"))));
                }

                requestModel.SchemaName = schemaname;
                requestModel.SearchText = searchtext;
                requestModel.Skip       = skip;
                requestModel.Limit      = limit;
                var validationResult = requestModel.Validate();
                if (validationResult != null && validationResult.Any())
                {
                    return(new CommonActionResult(CommonAPIResponse.BadRequest(validationResult)));
                }

                return(new CommonActionResult(MongoConnector.SearchData(requestModel)));
            }
            catch (Exception ex)
            {
                return(new CommonActionResult(CommonAPIResponse.InternalServerError(ex)));
            }
        }
Пример #24
0
        public IActionResult KGlobalSearch([FromRoute] string searchtext, [FromQuery] string websiteid, [FromQuery] int skip = 0, [FromQuery] int limit = 100)
        {
            try
            {
                var userId = AuthHelper.AuthorizeRequest(Request);
                if (string.IsNullOrEmpty(userId))
                {
                    return(new CommonActionResult(CommonAPIResponse.UnAuthorized()));
                }
                GlobalSearchDataRequestModel requestModel = new GlobalSearchDataRequestModel();
                requestModel.UserId = userId;

                if (string.IsNullOrEmpty(searchtext))
                {
                    return(new CommonActionResult(CommonAPIResponse.BadRequest(new System.ComponentModel.DataAnnotations.ValidationResult("Search text can not be empty"))));
                }
                else
                {
                    //Replace hyphen with space for the keywords
                    searchtext = searchtext.Replace('-', ' ');
                }

                requestModel.SearchText = searchtext;
                requestModel.Skip       = skip;
                requestModel.Limit      = limit;
                requestModel.WebsiteId  = websiteid;
                var validationResult = requestModel.Validate();
                if (validationResult != null && validationResult.Any())
                {
                    return(new CommonActionResult(CommonAPIResponse.BadRequest(validationResult)));
                }

                return(new CommonActionResult(MongoConnector.SearchGlobalData(requestModel)));
            }
            catch (Exception ex)
            {
                return(new CommonActionResult(CommonAPIResponse.InternalServerError(ex)));
            }
        }
        public IActionResult CreateNewWebsite([FromBody] CreateNewWebsiteRequestModel requestModel)
        {
            try
            {
                var developerId = AuthHelper.AuthorizeRequest(Request);
                if (string.IsNullOrEmpty(developerId))
                {
                    return(new CommonActionResult(CommonAPIResponse.UnAuthorized()));
                }

                try
                {
                    if (String.IsNullOrEmpty(requestModel.ClientId) && !String.IsNullOrEmpty(requestModel.ProjectId))
                    {
                        requestModel.ClientId = MongoConnector.GetClientIdFromProjectId(requestModel.ProjectId);
                    }
                }
                catch { }

                requestModel.DeveloperId     = developerId;
                requestModel.ActivateWebsite = false;
                if (requestModel.CopyDemoData)
                {
                    requestModel.ActivateWebsite = true;
                }
                var validationResult = requestModel.Validate();
                if (validationResult.Any())
                {
                    return(new CommonActionResult(CommonAPIResponse.BadRequest(validationResult)));
                }

                return(new CommonActionResult(MongoConnector.CreateNewWebsite(requestModel)));
            }
            catch (Exception ex)
            {
                return(new CommonActionResult(CommonAPIResponse.InternalServerError(ex)));
            }
        }
Пример #26
0
        public IActionResult GetLanguageEntity([FromRoute] string languageid)
        {
            try
            {
                string userId = AuthHelper.AuthorizeRequest(Request);

                var requestModel = new GetLanguageEntityRequestModel
                {
                    EntityId = languageid
                };
                var validationResult = requestModel.Validate();
                if (validationResult.Any())
                {
                    return(BadRequest(validationResult));
                }

                return(Ok(MongoConnector.GetLanguageEntity(requestModel)));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }
Пример #27
0
 public IActionResult GetWebsiteDataByPropertyPath([FromRoute] string schemaid, [FromBody] GetWebsiteDataByPropertyPath requestModel, [FromRoute] string clientid = null)
 {
     try
     {
         var userId = AuthHelper.AuthorizeRequest(Request);
         if (string.IsNullOrEmpty(userId) && (string.IsNullOrEmpty(clientid) || BasePluginConfigGenerator.GetBasePlugin(clientid).GetClientId() != clientid.Trim().ToUpper()))
         {
             return(new CommonActionResult(CommonAPIResponse.UnAuthorized()));
         }
         requestModel.SchemaId = schemaid;
         var validationResult = requestModel.Validate();
         if (validationResult.Any())
         {
             return(BadRequest(validationResult));
         }
         var result = MongoConnector.GetWebsiteDataByPropertyPath(requestModel);
         return(new CommonActionResult(CommonAPIResponse.OK(result)));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex));
     }
 }
Пример #28
0
        public IActionResult GetWebsiteData([FromQuery] string website, [FromQuery] string id = null,
                                            [FromQuery] int skip       = 0, [FromQuery] int limit = 100, [FromQuery] string query = null, [FromQuery] string sort = null,
                                            [FromQuery] string include = null, [FromRoute] string clientid = null, [FromRoute] string schemaid = null, [FromRoute] string schemaname = null)
        {
            try
            {
                var requestModel = new GetWebsiteDataRequestModel
                {
                    Limit      = limit,
                    Query      = query,
                    SchemaName = schemaname,
                    Skip       = skip,
                    Sort       = sort,
                    WebsiteId  = website,
                    Include    = include,
                    ClientId   = clientid,
                    SchemaId   = schemaid
                };

                var userId = AuthHelper.AuthorizeRequest(Request);
                if (string.IsNullOrEmpty(userId) && (string.IsNullOrEmpty(clientid) || BasePluginConfigGenerator.GetBasePlugin(clientid).GetClientId() != clientid.Trim().ToUpper()))
                {
                    return(new CommonActionResult(CommonAPIResponse.UnAuthorized()));
                }
                requestModel.UserId = userId;
                var validationResult = requestModel.Validate();
                if (validationResult.Any())
                {
                    return(BadRequest(validationResult));
                }
                return(Ok(MongoConnector.GetWebsiteData(requestModel)));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }
Пример #29
0
        public IActionResult GetPageData([FromRoute] string schemaname, [FromQuery] string websiteId, [FromQuery] string projectId, [FromQuery] string filePath, [FromQuery] string currentPageNumber)
        {
            try
            {
                var requestModel = new GetPageDataRequest
                {
                    ProjectId         = projectId,
                    SourcePath        = filePath,
                    WebsiteId         = websiteId,
                    SchemaName        = schemaname,
                    CurrentPageNumber = currentPageNumber
                };

                var userId = AuthHelper.AuthorizeRequest(Request);
                if (string.IsNullOrEmpty(userId))
                {
                    return(new CommonActionResult(CommonAPIResponse.UnAuthorized()));
                }
                else
                {
                    requestModel.UserId = userId;
                }

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

                var result = MongoConnector.GetBaseClassData(requestModel);
                return(Ok(result));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }
Пример #30
0
        public IActionResult AddClassProperty([FromRoute] string languageId, [FromRoute] string classname, [FromBody] KProperty kProperty)
        {
            try
            {
                var userId = string.Empty;
                userId = AuthHelper.AuthorizeRequest(Request);

                var tempCommand = new AddPropertyRequestModel()
                {
                    Property   = kProperty,
                    ClassName  = classname,
                    UserId     = userId,
                    LanguageId = languageId
                };

                List <System.ComponentModel.DataAnnotations.ValidationResult> validationResult = new List <System.ComponentModel.DataAnnotations.ValidationResult>();
                if (kProperty == null)
                {
                    validationResult.Add(new System.ComponentModel.DataAnnotations.ValidationResult("Property can not be null"));
                }
                else if (string.IsNullOrEmpty(kProperty.Name))
                {
                    validationResult.Add(new System.ComponentModel.DataAnnotations.ValidationResult("Property name can not be null"));
                }

                if (validationResult.Any())
                {
                    return(BadRequest(validationResult));
                }

                return(Ok(MongoConnector.AddPropertyToClass(tempCommand)));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }