示例#1
0
        public static IActionResult FeedbackDelete(
            [HttpTrigger(AuthorizationLevel.Anonymous, "delete", Route = "Feedback/{feedbackId}")]
            HttpRequest req,
            int feedbackId,
            ILogger log)
        {
            //create the input from the request parameter
            var input = new FeedbackDeleteInput {
                FeedbackId = feedbackId
            };

            //validate
            if (!input.IsValid())
            {
                return(new BadRequestObjectResult(input));
            }

            //call service passing input
            var output = ServiceFactory.DefaultService(log).FeedbackDelete(input);

            //check the return value - notice the enumeration
            if (output.ReturnValue == FeedbackDeleteOutput.Returns.NotFound)
            {
                return(new NotFoundResult());
            }

            //all good
            return(new OkObjectResult(output));
        }
        public void ValidDelete()
        {
            var input = new FeedbackDeleteInput
            {
                FeedbackId = 1
            };

            Assert.IsTrue(input.IsValid());

            //Call the service to get the output object
            var output = ServiceFactory.Data().FeedbackDelete(input);

            //We can test the return value against the enumeration for Deleted
            Assert.IsTrue(output.ReturnValue == FeedbackDeleteOutput.Returns.Ok);
        }