public HttpResponseMessage AddNotificationMethod(NotificationMethodDisplay method) { var response = Request.CreateResponse(HttpStatusCode.OK); try { var provider = _notificationContext.GetProviderByKey(method.ProviderKey); var gatewayResource = provider.ListResourcesOffered().FirstOrDefault(x => x.ServiceCode == method.ServiceCode); var newMethod = true; foreach (var nm in provider.NotificationMethods.Where(nm => nm.ServiceCode == gatewayResource.ServiceCode)) { newMethod = false; response = Request.CreateResponse(HttpStatusCode.InternalServerError, "Method for this resource already exists."); } if (newMethod) { var notificationGatewayMethod = provider.CreateNotificationMethod(gatewayResource, method.Name, method.ServiceCode); provider.SaveNotificationMethod(notificationGatewayMethod); } } catch (Exception ex) { response = Request.CreateResponse(HttpStatusCode.InternalServerError, string.Format("{0}", ex.Message)); } return response; }
public HttpResponseMessage AddNotificationMethod(NotificationMethodDisplay method) { var response = Request.CreateResponse(HttpStatusCode.OK); try { var provider = _notificationContext.GetProviderByKey(method.ProviderKey); var gatewayResource = provider.ListResourcesOffered().FirstOrDefault(x => x.ServiceCode == method.ServiceCode); var newMethod = true; foreach (var nm in provider.NotificationMethods.Where(nm => nm.ServiceCode == gatewayResource.ServiceCode)) { newMethod = false; response = Request.CreateResponse(HttpStatusCode.InternalServerError, "Method for this resource already exists."); } if (newMethod) { var notificationGatewayMethod = provider.CreateNotificationMethod(gatewayResource, method.Name, method.ServiceCode); provider.SaveNotificationMethod(notificationGatewayMethod); } } catch (Exception ex) { response = Request.CreateResponse(HttpStatusCode.InternalServerError, string.Format("{0}", ex.Message)); } return(response); }
public HttpResponseMessage PutNotificationMethod(NotificationMethodDisplay method) { var response = Request.CreateResponse(HttpStatusCode.OK); try { var provider = _notificationContext.GetProviderByKey(method.ProviderKey); var notificationMethod = provider.NotificationMethods.FirstOrDefault(x => x.Key == method.Key); notificationMethod = method.ToNotificationMethod(notificationMethod); provider.GatewayProviderService.Save(notificationMethod); } catch (Exception ex) { response = Request.CreateResponse(HttpStatusCode.InternalServerError, string.Format("{0}", ex.Message)); } return(response); }
public HttpResponseMessage PutNotificationMethod(NotificationMethodDisplay method) { var response = Request.CreateResponse(HttpStatusCode.OK); try { var provider = _notificationContext.GetProviderByKey(method.ProviderKey); var notificationMethod = provider.NotificationMethods.FirstOrDefault(x => x.Key == method.Key); notificationMethod = method.ToNotificationMethod(notificationMethod); provider.GatewayProviderService.Save(notificationMethod); } catch (Exception ex) { response = Request.CreateResponse(HttpStatusCode.InternalServerError, string.Format("{0}", ex.Message)); } return response; }