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); } }
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); }
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); }
public void SiteRequestFactoryCanGetDefaultManager() { ISiteRequestFactory _actualFactory = SiteRequestFactory.GetInstance(); var _manager = _actualFactory.GetSiteRequestManager(); Assert.IsInstanceOfType(_manager, typeof(ISiteRequestManager)); Assert.IsNotNull(_manager); }
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); }
public void SiteRequestManagerCanCreateNewRequest() { ISiteRequestFactory _actualFactory = SiteRequestFactory.GetInstance(); var _manager = _actualFactory.GetSiteRequestManager(); var _siteInfo = this.GetSiteRequestMock(); _manager.CreateNewSiteRequest(_siteInfo); }
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); }
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); }
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 void ProcessSiteRequests() { #region Process Approved Requests // Begin processing of approved requests Log.Info("Provisioning.Job.SiteProvisioningJob.ProcessSiteRequests", "Beginning Processing the site request repository"); var _siteManager = _requestFactory.GetSiteRequestManager(); var _requests = _siteManager.GetApprovedRequests(); Log.Info("Provisioning.Job.SiteProvisioningJob.ProcessSiteRequests", "There are {0} site requests pending in the repository.", _requests.Count); if (_requests.Count > 0) { this.ProvisionSites(_requests); } else { Log.Info("Provisioning.Job.SiteProvisioningJob.ProcessSiteRequests", "There are no site requests pending in the repository"); } // End processing of approved requests #endregion #region Process Failed or Incomplete Requests // Begin processing of failed requests (retry all that are not in approved or complete status) Log.Info("Provisioning.Job.SiteProvisioningJob.ProcessSiteRequests", "Beginning processing of the site request repository for failed or incomplete requests"); _siteManager = _requestFactory.GetSiteRequestManager(); _requests = _siteManager.GetIncompleteRequests(); Log.Info("Provisioning.Job.SiteProvisioningJob.ProcessSiteRequests", "There are {0} failed site requests pending in the repository.", _requests.Count); if (_requests.Count > 0) { this.ProvisionSites(_requests); } else { Log.Info("Provisioning.Job.SiteProvisioningJob.ProcessSiteRequests", "There are no failed site requests pending in the repository"); } // End processing of failed requests #endregion }
public void ProcessSiteRequests() { var _srManager = _requestFactory.GetSiteRequestManager(); var _requests = _srManager.GetApprovedRequests(); Log.Info("Provisioning.Job.SiteProvisioningJob.ProcessSiteRequests", "There is {0} Site Request Messages pending in the queue.", _requests.Count); //TODO LOG HOW MANY ITEMS if (_requests.Count > 0) { this.ProvisionSites(_requests); } else { Log.Info("Provisioning.Job.SiteProvisioningJob.ProcessSiteRequests", "There is no Site Request pending in the queue"); } }
public void ProcessSiteRequests() { Log.Info("Provisioning.Job.SiteProvisioningJob.ProcessSiteRequests", "Beginning Processing the site request repository"); var _siteManager = _requestFactory.GetSiteRequestManager(); var _requests = _siteManager.GetApprovedRequests(); Log.Info("Provisioning.Job.SiteProvisioningJob.ProcessSiteRequests", "There is {0} site requests pending in the repository.", _requests.Count); if (_requests.Count > 0) { this.ProvisionSites(_requests); } else { Log.Info("Provisioning.Job.SiteProvisioningJob.ProcessSiteRequests", "There is no site requests pending in the repository"); } }
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); } }
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); } }
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); }
public void SiteRequestManagerCanGetNewRequests() { ISiteRequestFactory _actualFactory = SiteRequestFactory.GetInstance(); var _manager = _actualFactory.GetSiteRequestManager(); var _newRequests = _manager.GetNewRequests(); }