Esempio n. 1
0
        public NewFlowCommandResult New([FromBody] NewFlowCommand command)
        {
            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 });

            NewFlowCommandResult result = (NewFlowCommandResult)_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);
        }
Esempio n. 2
0
        public ICommandResult Handle(UpdateFlowCommand command)
        {
            ICommandResult result = new CommandResult();

            _loggingService.Log(this.GetType(), ELogType.Neutral, ELogLevel.Debug, new { command.Owner, command.OwnerType, command.Object, command.Path, command.RequestHost }, "FlowCommandHandler.Handle(Update)");

            try
            {
                Flow flow = new Flow(command.Owner, command.OwnerType, command.Object, command.Path);

                if (flow.Valid)
                {
                    if (_flowRepository.CheckExists(command.Id))
                    {
                        if (!_flowRepository.CheckExists(flow.Path))
                        {
                            if (_flowRepository.Update(command.Id, flow))
                            {
                                result = new CommandResult(200);
                            }
                        }

                        else if (_flowRepository.Valid)
                        {
                            result = new CommandResult(400, new Notification("Path", "Already in Use"));
                        }
                    }

                    else if (_flowRepository.Valid)
                    {
                        result = new CommandResult(400, new Notification("Flow", "Could not be found"));
                    }
                }

                else
                {
                    result = new NewFlowCommandResult(400, flow.Notifications);
                }
            }
            catch (Exception e)
            {
                _loggingService.Log(this.GetType(), ELogType.Neutral, ELogLevel.Error, new { command.Owner, command.OwnerType, command.Object, command.Path, command.RequestHost }, e);
            }

            return(result);
        }