/// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            CreateNotificationResponse response = new CreateNotificationResponse();


            return(response);
        }
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>  
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            CreateNotificationResponse response = new CreateNotificationResponse();


            return response;
        }
        /// <inheritdoc />
        public async Task <CreateNotificationResponse> CreateNotification(CreateNotificationRequest request)
        {
            var newNot = new Models.Notification.Notification();

            newNot.NotificationPayload = request.Payload;
            newNot.NotificationType    = request.Type;
            newNot.CreatedDate         = request.DateCreated;
            newNot.UserID = request.UserId;

            _context.Notifications.Add(newNot);
            await _context.SaveChanges();

            CreateNotificationResponse response = new CreateNotificationResponse(HttpStatusCode.Created);

            return(response);
        }
        public async Task CreateNotification_ShouldReturnCreatedStatusCodeAsync()
        {
            // Arrange
            var requestDto = new CreateNotificationRequest(
                "Notification Test",
                NotificationTypeEnum.Email,
                this._mockedDate,
                1
                );
            var responseDto = new CreateNotificationResponse(HttpStatusCode.Created);

            _notificationRepoMock.Setup(n => n.CreateNotification(requestDto)).ReturnsAsync(responseDto);

            // Act
            var createdNotification = await _sut.CreateNotification(requestDto);

            // Assert
            Assert.Equal(responseDto, createdNotification);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Create a new notification on the Plot back-end server
        /// </summary>
        /// <param name="notification">Entity containing the v1 data of the notification to create</param>
        /// <returns>ID (string) of the created v1 notification</returns>
        public string CreateNotification(CreateNotificationV1 notification)
        {
            const string FunctionAdmin = "createNotification";
            const string Function      = "notification";

            notification.Check();

            CreateNotificationRequest request = new CreateNotificationRequest()
            {
                placeId   = notification.StoreId,
                message   = notification.Message,
                timespans = (notification.Timespans == null || notification.Timespans.Count() == 0) ? new CreateNotificationRequest.Timespan[] { } : notification.Timespans.Select(t => new CreateNotificationRequest.Timespan()
                {
                    start = t.Start.AsString(), end = t.End.AsString()
                }).ToArray(),
                data       = notification.Data,
                matchRange = notification.MatchRange,
                published  = notification.Published
            };

            HttpWebRequest webRequest = GetWebRequestAndSendRequest("POST", isAdminConnection ? FunctionAdmin : Function, request);

            CreateNotificationResponse response = GetJSONresponse <CreateNotificationResponse>(webRequest);

            // check the result codes:
            response.Check();

            string ret = response.Result;

            if (string.IsNullOrWhiteSpace(ret))
            {
                throw new Exception("No ID returned.");
            }

            return(ret);
        }