Esempio n. 1
0
        public ICommandResult Handle(NewFlowCommand command)
        {
            ICommandResult result = new NewFlowCommandResult();

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

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

                if (flow.Valid)
                {
                    if (!_flowRepository.CheckExists(flow.Path))
                    {
                        if (_flowRepository.Create(flow))
                        {
                            result = new NewFlowCommandResult(200, flow.Id);
                        }
                    }

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

                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);
        }