Esempio n. 1
0
        public ScoreResponseModel Create(ScoreRequestModel request)
        {
            ScoreCommand command = new ScoreCommand(request.Mark, request.StudentId, request.DisciplineId);
            Score        score   = createScoreHandler.Handle(command);

            ScoreResponseModel response = scoresMapper.Map(score);

            return(response);
        }
        /// <summary>
        /// Function for creating commands
        /// </summary>
        /// <param name="command">Command name</param>
        /// <returns>New command object</returns>
        public ICommand CreateCommand(string command)
        {
            ICommand resultCommand;

            if (this.commandDictionary.ContainsKey(command))
            {
                return(this.commandDictionary[command]);
            }

            switch (command)
            {
            case "u":
                resultCommand = new MoveUp();
                break;

            case "d":
                resultCommand = new MoveDown();
                break;

            case "l":
                resultCommand = new MoveLeft();
                break;

            case "r":
                resultCommand = new MoveRight();
                break;

            case "restart":
                resultCommand = new RestartCommand();
                break;

            case "top":
                resultCommand = new ScoreCommand();
                break;

            case "exit":
                resultCommand = new ExitCommand();
                break;

            case "undo":
                resultCommand = new UndoCommand();
                break;

            default:
                throw new InvalidCommandException(GlobalErrorMessages.InvalidCommandMessage);
            }

            this.commandDictionary.Add(command, resultCommand);
            return(resultCommand);
        }