public Models.SiteMetadata GetSitePolices([FromBody] string value)
        {
            SiteEditMetadata _metadata = new SiteEditMetadata();
            var _request = JsonConvert.DeserializeObject <Models.SiteMetadata>(value);

            _request.Success = false;

            _metadata.TenantAdminUrl = _request.TenantAdminUrl;
            _metadata.Url            = _request.Url;

            try
            {
                IMetadataFactory _factory = MetadataFactory.GetInstance();
                IMetadataManager _manager = _factory.GetManager();
                var _results = _manager.SetSitePolicy(_metadata);
                _request.Success = true;
                return(_request);
            }
            catch (Exception _ex)
            {
                _request.ErrorMessage = _ex.Message;
                OfficeDevPnP.Core.Diagnostics.Log.Error("MetadataController.GetSiteMetadata",
                                                        "There was an error processing the request. Exception: {0}",
                                                        _ex);
                return(_request);
            }
        }
Beispiel #2
0
        public void CanCreateNewSiteClassification()
        {
            IMetadataFactory _factory   = MetadataFactory.GetInstance();
            IMetadataManager _manager   = _factory.GetManager();
            var _siteClassificationMock = GetMock();

            _manager.CreateNewSiteClassification(_siteClassificationMock);
        }
Beispiel #3
0
        public void CanGetInstanceManager()
        {
            IMetadataFactory _factory = MetadataFactory.GetInstance();
            IMetadataManager _manager = _factory.GetManager();

            Assert.IsInstanceOfType(_manager, typeof(IMetadataManager));
            Assert.IsNotNull(_manager);
        }
Beispiel #4
0
        public void CanGetSiteClassificationByName()
        {
            IMetadataFactory _factory = MetadataFactory.GetInstance();
            IMetadataManager _manager = _factory.GetManager();

            var _expectedMock = GetMock();
            var _actualMock   = _manager.GetSiteClassificationByName(_expectedMock.Key);

            Assert.AreEqual(_expectedMock.Key, _actualMock.Key);
        }
Beispiel #5
0
 public HttpResponseMessage GetSitePolices()
 {
     try
     {
         IMetadataFactory _factory = MetadataFactory.GetInstance();
         IMetadataManager _manager = _factory.GetManager();
         var _siteClassifications  = _manager.GetAvailableSiteClassifications();
         return(Request.CreateResponse(HttpStatusCode.OK, _siteClassifications));
     }
     catch (Exception _ex)
     {
         var _message = string.Format("There was an error processing the request. {0}", _ex.Message);
         Log.Error("MetadataController.GetSitePolices", "There was an error processing the request. Exception: {0}", _ex);
         HttpResponseMessage _response = Request.CreateResponse(HttpStatusCode.InternalServerError, _message);
         throw new HttpResponseException(_response);
     }
 }
        public Models.SiteMetadata SetSiteMetadata([FromBody] string value)
        {
            ConfigManager _cfgmanager = new ConfigManager();
            var           _auth       = new AppOnlyAuthenticationTenant();

            _auth.TenantAdminUrl = _cfgmanager.GetAppSettingsKey("TenantAdminUrl");

            var _request = JsonConvert.DeserializeObject <Models.SiteMetadata>(value);

            _request.TenantAdminUrl = _auth.TenantAdminUrl;

            // Transform the request
            var _metadataRequest = ObjectMapper.ToSiteEditMetadata(_request);

            _metadataRequest.Success = false;

            try
            {
                IMetadataFactory _factory = MetadataFactory.GetInstance();
                IMetadataManager _manager = _factory.GetManager();
                var _metadataResponse     = _manager.SetSiteMetadata(_metadataRequest);
                _metadataResponse.Success = true;

                // Transform response
                var _response = ObjectMapper.ToSiteMetadata(_metadataResponse);
                return(_response);
            }
            catch (Exception _ex)
            {
                _request.ErrorMessage = _ex.Message;
                OfficeDevPnP.Core.Diagnostics.Log.Error("MetadataController.SetSiteMetadata",
                                                        "There was an error processing the request. Exception: {0}",
                                                        _ex);
                return(_request);
            }
        }
Beispiel #7
0
 public void CanGetEnabledSiteClassifications()
 {
     IMetadataFactory _factory = MetadataFactory.GetInstance();
     IMetadataManager _manager = _factory.GetManager();
     var _actual = _manager.GetAvailableSiteClassifications();
 }