コード例 #1
0
        public WebResponseDto <TOut> Execute(TDto dto)
        {
            var webResponseDto = new WebResponseDto <TOut>();

            try
            {
                var handler = _serviceProvider.GetService(typeof(IWebHandler <TDto, TOut>));
                if (handler == null)
                {
                    throw new NullReferenceException("Handler was not found");
                }
                ((IWebHandler <TDto, TOut>)handler).Handle(dto, webResponseDto);
                return(webResponseDto);
            }
            catch (Exception e)
            {
                webResponseDto.AddError("EW1", new[] { e.Message });
                return(webResponseDto);
            }
            finally
            {
                if (webResponseDto.Messages.Any(a => a.Type == MessageDtoType.Error))
                {
                    if (webResponseDto.Messages.Any(a => a.Key.Equals("E3")))
                    {
                        _navigation.GoTo("/LoginRedirect");
                    }
                    _onFail?.Invoke(webResponseDto);
                }
                else
                {
                    _onSuccess?.Invoke(webResponseDto);
                }
            }
        }
コード例 #2
0
        public IWebResponseDto <TOut> Execute <TDto, TOut>(TDto dto) where TOut : new()
        {
            IWebResponseDto <TOut> T = new WebResponseDto <TOut>();

            T.Configuration = new Configuration()
            {
                DateFormat     = _configuration["DateFormat"],
                DateTimeFormat = _configuration["DateTimeFormat"]
            };
            try
            {
                var handler = _serviceProvider.GetService(typeof(IWebHandler <TDto, TOut>));
                ((IWebHandler <TDto, TOut>)handler).Handle(dto, T);
                return(T);
            }
            catch (Exception e)
            {
                T.AddError("EW1", new[] { e.Message });
                return(T);
            }
        }