Beispiel #1
0
        public void SiteRequestFactoryCanGetInstance()
        {
            ISiteRequestFactory _actualFactory = SiteRequestFactory.GetInstance();

            Assert.IsNotNull(_actualFactory);
            Assert.IsInstanceOfType(_actualFactory, typeof(ISiteRequestFactory));
        }
Beispiel #2
0
        public HttpResponseMessage GetOwnerRequestsByEmail([FromBody] string ownerEmailAddress)
        {
            try
            {
                var _user = JsonConvert.DeserializeObject <SiteUser>(ownerEmailAddress);
                ISiteRequestFactory _requestFactory = SiteRequestFactory.GetInstance();
                var _manager      = _requestFactory.GetSiteRequestManager();
                var _siteRequests = _manager.GetOwnerRequests(_user.Name);
                return(Request.CreateResponse((HttpStatusCode)200, _siteRequests));
            }
            catch (JsonSerializationException _ex)
            {
                var _message = string.Format("There was an error with the data. Exception {0}", _ex.Message);

                Log.Error("SiteRequestController.GetOwnerRequestsByEmail",
                          "There was an error get site requests by email. Error Message {0} Error Stack {1}",
                          _ex.Message,
                          _ex);

                HttpResponseMessage _response = Request.CreateResponse(HttpStatusCode.BadRequest, _message);
                throw new HttpResponseException(_response);
            }
            catch (Exception _ex)
            {
                var _message = string.Format("There was an error processing the request. {0}", _ex.Message);
                Log.Error("SiteRequestController.GetOwnerRequestsByEmail", "There was an error processing the request. Exception: {0}", _ex);
                HttpResponseMessage _response = Request.CreateResponse(HttpStatusCode.InternalServerError, _message);
                throw new HttpResponseException(_response);
            }
        }
Beispiel #3
0
        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 #4
0
        public SiteCheckResponse ValidateNewSiteRequestUrl([FromBody] string value)
        {
            var _response = new SiteCheckResponse();

            _response.Success = false;

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

                ///Save the Site Request
                ISiteRequestFactory _srf = SiteRequestFactory.GetInstance();
                var  _manager            = _srf.GetSiteRequestManager();
                bool _value = _manager.DoesSiteRequestExist(_requestToCheck.Url);
                _response.DoesExist = _value;
                _response.Success   = true;
            }
            catch (Exception ex)
            {
                Log.Error("SiteRequestController.ValidateNewSiteRequestUrl",
                          "There was an error processing your request. Error Message {0} Error Stack {1}",
                          ex.Message,
                          ex);
                _response.ErrorMessage = ex.Message;
            }
            return(_response);
        }
Beispiel #5
0
 public SiteProvisioningJob()
 {
     this._configFactory = ConfigurationFactory.GetInstance();
     this._appManager = _configFactory.GetAppSetingsManager();
     this._settings = _appManager.GetAppSettings();
     this._requestFactory = SiteRequestFactory.GetInstance();
     this._siteTemplateFactory = SiteTemplateFactory.GetInstance();
 }
Beispiel #6
0
 public SiteProvisioningJob()
 {
     this._configFactory       = ConfigurationFactory.GetInstance();
     this._appManager          = _configFactory.GetAppSetingsManager();
     this._settings            = _appManager.GetAppSettings();
     this._requestFactory      = SiteRequestFactory.GetInstance();
     this._siteTemplateFactory = SiteTemplateFactory.GetInstance();
 }
Beispiel #7
0
        public void SiteRequestFactoryCanGetDefaultManager()
        {
            ISiteRequestFactory _actualFactory = SiteRequestFactory.GetInstance();
            var _manager = _actualFactory.GetSiteRequestManager();

            Assert.IsInstanceOfType(_manager, typeof(ISiteRequestManager));
            Assert.IsNotNull(_manager);
        }
Beispiel #8
0
        public void SiteRequestCanGetRequestByUrl()
        {
            ISiteRequestFactory _actualFactory = SiteRequestFactory.GetInstance();
            var _manager  = _actualFactory.GetSiteRequestManager();
            var _expected = this.GetSiteRequestMock();
            var _actual   = _manager.GetSiteRequestByUrl(_expected.Url);

            Assert.AreEqual(_expected.Url, _actual.Url);
        }
Beispiel #9
0
        public void SiteRequestManagerCanCreateNewRequest()
        {
            ISiteRequestFactory _actualFactory = SiteRequestFactory.GetInstance();
            var _manager = _actualFactory.GetSiteRequestManager();

            var _siteInfo = this.GetSiteRequestMock();

            _manager.CreateNewSiteRequest(_siteInfo);
        }
Beispiel #10
0
        public void SiteRequestManagerDoesRequestByUrl()
        {
            var _expectValue = true;
            ISiteRequestFactory _actualFactory = SiteRequestFactory.GetInstance();
            var _manager = _actualFactory.GetSiteRequestManager();
            var _mock    = this.GetSiteRequestMock();
            var _actual  = _manager.DoesSiteRequestExist(_mock.Url);

            Assert.AreEqual(_expectValue, _actual);
        }
Beispiel #11
0
        public void SiteRequestManagerCanUpdateRequestStatus()
        {
            ISiteRequestFactory _actualFactory = SiteRequestFactory.GetInstance();
            var _manager  = _actualFactory.GetSiteRequestManager();
            var _expected = this.GetSiteRequestMock();

            _manager.UpdateRequestStatus(_expected.Url, SiteRequestStatus.Approved);
            var _actual = _manager.GetSiteRequestByUrl(_expected.Url);

            Assert.AreEqual <string>(_actual.RequestStatus, SiteRequestStatus.Approved.ToString());
            Assert.AreEqual(_expected.Url, _actual.Url);
        }
Beispiel #12
0
        public void SiteRequestManagerCanGetOwnerRequestsByEmail()
        {
            ISiteRequestFactory _actualFactory = SiteRequestFactory.GetInstance();
            var _manager  = _actualFactory.GetSiteRequestManager();
            var _expected = this.GetSiteRequestMock();

            var _actualRequests = _manager.GetOwnerRequests(_expected.SiteOwner.Name);

            foreach (var _actualRequest in _actualRequests)
            {
                Assert.AreEqual(_actualRequest.SiteOwner.Name, _expected.SiteOwner.Name);
            }
        }
        public HttpResponseMessage CreateSiteRequest([FromBody] string value)
        {
            SiteRequest _data = null;

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

                // Handle the case when the URL is null - ie, were going to generate the URL later
                if (_newRequest.Url == null)
                {
                    _newRequest.Url = "uri://autogenerate/" + Guid.NewGuid().ToString("N");
                }

                ///Save the Site Request
                ISiteRequestFactory _srf = SiteRequestFactory.GetInstance();
                var _manager             = _srf.GetSiteRequestManager();

                _manager.CreateNewSiteRequest(_newRequest);
                return(Request.CreateResponse <SiteRequest>(HttpStatusCode.Created, _data));
            }
            catch (JsonSerializationException _ex)
            {
                var _message = string.Format("There was an error with the data. Exception {0}", _ex.Message);

                Log.Error("SiteRequestController.CreateSiteRequest",
                          "There was an error creating the new site request. Error Message {0} Error Stack {1}",
                          _ex.Message,
                          _ex);

                HttpResponseMessage _response = Request.CreateResponse(HttpStatusCode.BadRequest, _message);
                throw new HttpResponseException(_response);
            }

            catch (Exception _ex)
            {
                var _message = string.Format("There was an error processing the request. Exception {0}", _ex.Message);
                HttpResponseMessage _response = Request.CreateResponse(HttpStatusCode.InternalServerError, _message);

                Log.Error("SiteRequestController.CreateSiteRequest",
                          "There was an error creating the new site request. Error Message {0} Error Stack {1}",
                          _ex.Message,
                          _ex);
                throw new HttpResponseException(_response);
            }
        }
Beispiel #14
0
        public HttpResponseMessage GetSiteRequest([FromBody] string value)
        {
            try
            {
                var _data           = JsonConvert.DeserializeObject <SiteRequest>(value);
                var _requestToCheck = ObjectMapper.ToSiteRequestInformation(_data);

                ISiteRequestFactory _srf = SiteRequestFactory.GetInstance();
                var _manager             = _srf.GetSiteRequestManager();
                var _siteRequest         = _manager.GetSiteRequestByUrl(_data.Url);
                if (_siteRequest == null)
                {
                    var _message = string.Format("The site request url {0} does not exist", _requestToCheck.Url);
                    HttpResponseMessage _response = Request.CreateResponse(HttpStatusCode.NotFound, _message);
                    throw new HttpResponseException(_response);
                }
                else
                {
                    return(Request.CreateResponse <SiteInformation>(HttpStatusCode.OK, _siteRequest));
                }
            }
            catch (HttpResponseException)
            {
                throw;
            }
            catch (JsonException _ex)
            {
                var _message = string.Format("There was an error with the data. Exception {0}", _ex.Message);
                Log.Error("SiteRequestController.GetSiteRequest",
                          "There was an error processing the request. Error Message {0} Error Stack {1}",
                          _ex.Message,
                          _ex);
                HttpResponseMessage _response = Request.CreateResponse(HttpStatusCode.BadRequest, _message);
                throw new HttpResponseException(_response);
            }
            catch (Exception _ex)
            {
                var _message = string.Format("There was an error with the data. Exception {0}", _ex.Message);
                Log.Error("SiteRequestController.GetSiteRequest",
                          "There was an error processing your request. Error Message {0} Error Stack {1}",
                          _ex.Message,
                          _ex);
                HttpResponseMessage _response = Request.CreateResponse(HttpStatusCode.InternalServerError, _message);
                throw new HttpResponseException(_response);
            }
        }
Beispiel #15
0
        public SiteRequestsResponse GetOwnerRequestsByEmail([FromBody] string ownerEmailAddress)
        {
            var _returnResponse = new SiteRequestsResponse();

            _returnResponse.Success = false;
            var _user = JsonConvert.DeserializeObject <SiteUser>(ownerEmailAddress);

            try
            {
                ISiteRequestFactory _requestFactory = SiteRequestFactory.GetInstance();
                var _manager = _requestFactory.GetSiteRequestManager();
                _returnResponse.SiteRequests = _manager.GetOwnerRequests(_user.Name);
                _returnResponse.Success      = true;
            }
            catch (Exception _ex)
            {
                _returnResponse.ErrorMessage = _ex.Message;
                Log.Error("SiteRequestController.GetOwnerRequestsByEmail", "There was an error processing the request. Exception: {0}", _ex);
            }

            return(_returnResponse);
        }
Beispiel #16
0
 public void SiteRequestManagerCanGetNewRequests()
 {
     ISiteRequestFactory _actualFactory = SiteRequestFactory.GetInstance();
     var _manager     = _actualFactory.GetSiteRequestManager();
     var _newRequests = _manager.GetNewRequests();
 }