// PUT /api/applications/5 public HttpResponseMessage Put(String id, ApplicationModels.UpdateApplicationRequest request) { var application = GetApplication(id); if (application == null) { var response = new HttpResponseMessage <ApplicationModels.ApplicationResponse>(HttpStatusCode.BadRequest); response.ReasonPhrase = "Invalid Application"; return(response); } //TODO: check to make sure passed in id is the calling application try { application.Url = request.url; } catch (Exception ex) { //TODO: log exception var message = new HttpResponseMessage(HttpStatusCode.InternalServerError); message.ReasonPhrase = ex.Message; return(message); } return(new HttpResponseMessage(HttpStatusCode.OK)); }
// PUT /api/applications/5 public HttpResponseMessage Put(String id, ApplicationModels.UpdateApplicationRequest request) { DomainServices.ApplicationService applicationService = new DomainServices.ApplicationService(_ctx); Guid apiKey; Guid.TryParse(id, out apiKey); if (apiKey == null) { _logger.Log(LogLevel.Error, String.Format("Exception Updating Application. ApiKey {0} could not be parsed as a GUID.", id)); var message = new HttpResponseMessage(HttpStatusCode.BadRequest); message.ReasonPhrase = "Invalid ApiKey. Cannot be parsed to GUID."; return(message); } Application application = null; try { application = applicationService.GetApplication(id); } catch (Exception ex) { _logger.Log(LogLevel.Error, String.Format("Unhandled Exception Deleting Application. Application with the API Key {0} not found. {0}", id, ex.Message)); var message = new HttpResponseMessage(HttpStatusCode.NotFound); message.ReasonPhrase = "Application Resource Not Found."; return(message); } try { application.IsActive = request.isActive; application.ApplicationName = request.name; application.Url = request.url; applicationService.UpdateApplication(application); } catch (Exception ex) { _logger.Log(LogLevel.Error, String.Format("Unhandled Exception updating application {0}. {1}", id, ex.Message)); var message = new HttpResponseMessage(HttpStatusCode.InternalServerError); message.ReasonPhrase = ex.Message; return(message); } return(new HttpResponseMessage(HttpStatusCode.OK)); }