예제 #1
0
        /// <summary>
        /// Prepares based on ActionResponseBuilder, an IActionResult with a BadRequestResult response
        /// </summary>
        /// <typeparam name="T">Generic object for value</typeparam>
        /// <param name="actionResponseBuilder">ActionResponseBuilder prepared in the process</param>
        /// <param name="exception">Exception raised</param>
        /// <returns>BadRequestObjectResult with errors in ActionResponse and StatusCode of 400</returns>
        protected IActionResult Ko <T>(ActionResponseBuilder <T> actionResponseBuilder, Exception exception)
        {
            _logger.LogError(exception, null);

            actionResponseBuilder.AddError(new ErrorMessage(ErrorType.Invalid, exception.Message));

            return(BadRequest(actionResponseBuilder.Build()));
        }
        public void Given_Data_When_ConstructorInvoked_Then_ActionResponseBuilderWithDataRetrived()
        {
            var data = DateTime.Now;

            var actionResponseBuilder = new ActionResponseBuilder <DateTime>(data);
            var builtActionResponse   = actionResponseBuilder.Build();

            Assert.AreEqual(data, builtActionResponse.Data);
        }
예제 #3
0
 /// <summary>
 /// Prepares based on ActionResponseBuilder, an IActionResult
 /// </summary>
 /// <typeparam name="T">Generic object for value</typeparam>
 /// <param name="actionResponseBuilder">ActionResponseBuilder prepared in the process</param>
 /// <returns>OkObjectResult with value data in ActionResponse and StatusCode of 200</returns>
 protected IActionResult Ok <T>(ActionResponseBuilder <T> actionResponseBuilder)
 {
     return(Ok(actionResponseBuilder.Build()));
 }