예제 #1
0
        public ICommandResult Handle(GetFlowCommand command)
        {
            ICommandResult result = new GetFlowCommandResult();

            _loggingService.Log(this.GetType(), ELogType.Neutral, ELogLevel.Debug, new { command.Flow, command.RequestHost }, "FlowCommandHandler.Handle(Get)");

            try
            {
                if (_flowRepository.CheckExists(command.Flow))
                {
                    Flow flow = _flowRepository.Get(command.Flow);

                    if (flow != null)
                    {
                        result = new GetFlowCommandResult(200, flow.Owner, flow.OwnerType, flow.Object, flow.CreationDate, flow.Path);
                    }
                }

                else if (_flowRepository.Valid)
                {
                    result = new GetFlowCommandResult(400, new Notification("Flow", "Could not be found"));
                }
            }
            catch (Exception e)
            {
                _loggingService.Log(this.GetType(), ELogType.Neutral, ELogLevel.Error, new { command.Flow, command.RequestHost }, e);
            }

            return(result);
        }
예제 #2
0
        public GetFlowCommandResult Get(Guid id)
        {
            GetFlowCommand command = new GetFlowCommand()
            {
                Flow = id
            };

            command.setRequestHost(HttpContext.Request.Host.ToString());

            _loggingService.Log(this.GetType(), ELogType.Input, ELogLevel.Info, new { Flow = this.User.Identity.Name, Path = this.Request.Path, Method = this.Request.Method });

            GetFlowCommandResult result = (GetFlowCommandResult)_flowHandler.Handle(command);

            _loggingService.Log(this.GetType(), ELogType.Output, ELogLevel.Info, new { Flow = this.User.Identity.Name, Path = this.Request.Path, Method = this.Request.Method, Code = this.Response.StatusCode });

            HttpContext.Response.StatusCode = result.Code;

            return(result);
        }