コード例 #1
0
        public void retrievefornotificationsError()
        {
            //Arrange
            RetrieveNotification notification = new RetrieveNotification()
            {
                Teacher      = "",
                Notification = ""
            };

            // Act
            var badResponse = _controller.retrievefornotifications(notification);

            // Assert
            Assert.IsType <BadRequestObjectResult>(badResponse);
        }
コード例 #2
0
        public void retrievefornotifications()
        {
            //Arrange
            RetrieveNotification notification = new RetrieveNotification()
            {
                Teacher      = "*****@*****.**",
                Notification = "Hello students!"
            };

            // Act
            var okResult = _controller.retrievefornotifications(notification);

            // Assert
            Assert.IsType <OkObjectResult>(okResult);
        }
コード例 #3
0
        public IActionResult retrievefornotifications(RetrieveNotification retrieveNotification)
        {
            try
            {
                if (String.IsNullOrEmpty(retrieveNotification.Teacher) || String.IsNullOrEmpty(retrieveNotification.Notification))
                {
                    processingError = badrequest;
                    throw new ProcessingException();
                }

                //Extract teacher and notification from request body
                string teacher      = retrieveNotification.Teacher.ToString();
                string notification = retrieveNotification.Notification.ToString();

                var recipients = _ihiringRepositorty.retrievefornotifications(teacher, notification);

                if (recipients == null)
                {
                    processingError = notfound;
                    throw new ProcessingException();
                }

                return(Ok(JsonConvert.SerializeObject(recipients, Formatting.Indented)));
            }
            catch (ProcessingException)
            {
                // TO-DO: Handle processing exception
                error error = new error
                {
                    message = processingError.ToString()
                };
                return(BadRequest(error));
            }
            catch (Exception)
            {
                // TO-DO: Handle the non processing related exception
                return(BadRequest());
            }
        }