public SiteRequest NewSiteRequest([FromBody]string value)
        {
            var _response = new SiteRequest();
           _response.Success = false;

            try
            {
                var data = JsonConvert.DeserializeObject<SiteRequest>(value);
                var _newRequest = ObjectMapper.ToSiteRequestInformation(data);

                ///Save the Site Request
                ISiteRequestFactory _srf = SiteRequestFactory.GetInstance();
                var _manager = _srf.GetSiteRequestManager();
                _manager.CreateNewSiteRequest(_newRequest);
                _response.Success = true;
            }
            catch (Exception ex)
            {
                Log.Error("SiteRequestController.NewSiteRequest",
                    "There was an error saving the new site request. Error Message {0} Error Stack {1}",
                    ex.Message,
                    ex);
                _response.ErrorMessage = ex.Message;
            }
            return _response;

        }
Beispiel #2
0
        public static SiteInformation ToSiteRequestInformation(SiteRequest request)
        {
            var _owner = new SiteUser()
            {
                Name = request.PrimaryOwner
            };

            List<SiteUser> _additionalAdmins = new List<SiteUser>();
            foreach (var secondaryOwner in request.AdditionalAdministrators)
            {
                if(!string.IsNullOrEmpty(secondaryOwner))
                {
                    var _sharePointUser = new SiteUser();
                    _sharePointUser.Name = secondaryOwner;
                    _additionalAdmins.Add(_sharePointUser);
                }
            }

            var _newRequest = new SiteInformation();
            _newRequest.Title = request.Title;
            _newRequest.Description = request.Description;
            _newRequest.Url = request.Url;
            _newRequest.TimeZoneId = request.TimeZoneID;
            _newRequest.Lcid = request.lcid;
            _newRequest.Template = request.Template;
            _newRequest.SitePolicy = request.SitePolicy;
            _newRequest.SiteOwner = _owner;
            _newRequest.AdditionalAdministrators = _additionalAdmins;
            _newRequest.SharePointOnPremises = request.SharePointOnPremises;
            _newRequest.BusinessCase = request.BusinessCase;
            _newRequest.EnableExternalSharing = request.EnableExternalSharing;
            _newRequest.IsConfidential = request.IsConfidential;


            if(request.Properties != null)
            {
                //Serialize Property Bag Entries
                _newRequest.SiteMetadataJson = JsonConvert.SerializeObject(request.Properties);
            }
            return _newRequest;
        }