Exemple #1
0
        public HttpResponseMessage UpdateNotificationMessage(NotificationMessageDisplay message)
        {
            var response = Request.CreateResponse(HttpStatusCode.OK);

            try
            {
                var provider = _notificationContext.GetProviderByMethodKey(message.MethodKey);

                var method = provider.GetNotificationGatewayMethodByKey(message.MethodKey);

                var notificationMessage = method.NotificationMessages.FirstOrDefault(x => x.Key == message.Key);

                if (notificationMessage == null)
                {
                    response = Request.CreateResponse(HttpStatusCode.InternalServerError, "Notification Message Not Found");
                }

                method.SaveNotificationMessage(message.ToNotificationMessage(notificationMessage));

                return(response);
            }
            catch (Exception ex)
            {
                response = Request.CreateResponse(HttpStatusCode.InternalServerError, string.Format("{0}", ex.Message));
            }

            return(response);
        }
        public string PutNotificationMessage(NotificationMessageDisplay message)
        {
            try
            {
                var provider = _notificationContext.GetProviderByMethodKey(message.MethodKey);

                var method = provider.GetNotificationGatewayMethodByKey(message.MethodKey);

                var notificationMessage = new NotificationMessage(message.MethodKey, message.Name, message.FromAddress);

                method.SaveNotificationMessage(message.ToNotificationMessage(notificationMessage));

                return(notificationMessage.Key.ToString());
            }
            catch (Exception ex)
            {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.InternalServerError, string.Format("{0}", ex.Message)));
            }
        }
        public HttpResponseMessage UpdateNotificationMessage(NotificationMessageDisplay message)
        {
            var response = Request.CreateResponse(HttpStatusCode.OK);

            try
            {

                var provider = _notificationContext.GetProviderByMethodKey(message.MethodKey);

                var method = provider.GetNotificationGatewayMethodByKey(message.MethodKey);

                var notificationMessage = method.NotificationMessages.FirstOrDefault(x => x.Key == message.Key);

                if (notificationMessage == null)
                {
                    response = Request.CreateResponse(HttpStatusCode.InternalServerError, "Notification Message Not Found");
                }

                method.SaveNotificationMessage(message.ToNotificationMessage(notificationMessage));

                return response;
            }
            catch (Exception ex)
            {
                response = Request.CreateResponse(HttpStatusCode.InternalServerError, string.Format("{0}", ex.Message));
            }

            return response;
        }
        public string PutNotificationMessage(NotificationMessageDisplay message)
        {
            try
            {
                var provider = _notificationContext.GetProviderByMethodKey(message.MethodKey);

                var method = provider.GetNotificationGatewayMethodByKey(message.MethodKey);

                var notificationMessage = new NotificationMessage(message.MethodKey, message.Name, message.FromAddress)
                                              {
                                                  BodyTextIsFilePath
                                                      =
                                                      message
                                                      .BodyTextIsFilePath
                                              };
                method.SaveNotificationMessage(message.ToNotificationMessage(notificationMessage));

                return notificationMessage.Key.ToString();
            }
            catch (Exception ex)
            {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.InternalServerError, string.Format("{0}", ex.Message)));
            }
        }
        public HttpResponseMessage PutNotification(NotificationMessageDisplay notificationDisplay)
        {
            var response = Request.CreateResponse(HttpStatusCode.OK);

            try
            {
                var notification = _notificationMessageService.GetByKey(notificationDisplay.Key);
                notification = notificationDisplay.ToNotificationMessage(notification);

                _notificationMessageService.Save(notification);
            }
            catch (Exception ex)
            {
                response = Request.CreateResponse(HttpStatusCode.NotFound, string.Format("{0}", ex.Message));
            }

            return response;
        }
        public NotificationMessageDisplay NewNotification(NotificationMessageDisplay notificationDisplay)
        {
            INotificationMessage notification;

            try
            {
                throw new NotImplementedException();
                notification = notificationDisplay.ToNotificationMessage(notification);
                var existingNotification = _notificationMessageService.GetByKey(notification.Key);
                if (existingNotification != null)
                {
                    throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.Conflict));
                }

                _notificationMessageService.Save(notification);
            }
            catch (Exception e)
            {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.InternalServerError));
            }

            return notification.ToNotificationMessageDisplay();
        }