Esempio n. 1
0
 public TheatreEngine(IPerformanceDatabase performanceDatabase, ICommandFactory commandFactory, IInputHandler inputHandler, IRenderer renderer)
 {
     this.PerformanceDatabase = performanceDatabase;
     this.CommandFactory      = commandFactory;
     this.InputHandler        = inputHandler;
     this.Renderer            = renderer;
 }
Esempio n. 2
0
        public static string ExecutePrintAllPerformancesCommand(IPerformanceDatabase database)
        {
            var performances = database.ListAllPerformances().ToList();
            if (!performances.Any())
            {
                return "No performances";
            }

            var sb = new StringBuilder();

            //sb.AppendFormat("({0}, {1}, {2}), ",
            //        performances[0].PerformanceTitle,
            //        performances[0].TheatreName,
            //        performances[0].StartDateTime.ToString("dd.MM.yyyy HH:mm"));

            for (int i = 0; i < performances.Count; i++)
            {
                sb.AppendFormat("({0}, {1}, {2}), ",
                    performances[i].PerformanceTitle,
                    performances[i].TheatreName,
                    performances[i].StartDateTime.ToString("dd.MM.yyyy HH:mm"));
            }

            return sb.ToString().Trim(' ', ',');
        }
Esempio n. 3
0
        public static string ExecutePrintAllPerformancesCommand(IPerformanceDatabase database)
        {
            var performances = database.ListAllPerformances().ToList();

            if (!performances.Any())
            {
                return("No performances");
            }

            var sb = new StringBuilder();

            //sb.AppendFormat("({0}, {1}, {2}), ",
            //        performances[0].PerformanceTitle,
            //        performances[0].TheatreName,
            //        performances[0].StartDateTime.ToString("dd.MM.yyyy HH:mm"));

            for (int i = 0; i < performances.Count; i++)
            {
                sb.AppendFormat("({0}, {1}, {2}), ",
                                performances[i].PerformanceTitle,
                                performances[i].TheatreName,
                                performances[i].StartDateTime.ToString("dd.MM.yyyy HH:mm"));
            }

            return(sb.ToString().Trim(' ', ','));
        }
Esempio n. 4
0
        public static string ExecuteAddTheatreCommand(string[] parameters, IPerformanceDatabase database)
        {
            string theatreName = parameters[0];

            database.AddTheatre(theatreName);
            return("Theatre added");
        }
        public static string ExecuteAddTheatreCommand(string[] parameters, IPerformanceDatabase database)
        {
            string theatreName = parameters[0];
            database.AddTheatre(theatreName);

            return "Theatre added";
        }
Esempio n. 6
0
        public static string ExecutePrintAllPerformancesCommand(IPerformanceDatabase dataBase)
        {
            var performances = dataBase.ListAllPerformances().ToList();
            var result = string.Empty;
            if (performances.Any())
            {
                for (var i = 0; i < performances.Count; i++)
                {
                    var sb = new StringBuilder();
                    sb.Append(result);
                    if (i > 0)
                    {
                        sb.Append(", ");
                    }
                    var result1 = performances[i].Date.ToString("dd.MM.yyyy HH:mm");
                    sb.AppendFormat(
                        "({0}, {1}, {2})", performances
                            [i].PefrofmanceName, performances[i].Theatre, result1);
                    result = sb + "";
                }
                return result;
            }

            return "No performances";
        }
        public static string ExecutePrintAllPerformancesCommand(IPerformanceDatabase database)
        {
            var performances = database.ListAllPerformances().ToList();
            var performanceOutput = new StringBuilder();
            if (!performances.Any())
            {
                return "No performances";
            }

            for (int i = 0; i < performances.Count; i++)
            {
                //PERFORMANCE
                if (i > 0)
                {
                    performanceOutput.Append(", ");
                }

                string startDateTimeAsString = performances[i].StartDateTime.ToString("dd.MM.yyyy HH:mm");
                performanceOutput.AppendFormat(
                    "({0}, {1}, {2})",
                    performances[i].PerformanceTitle,
                    performances[i].TheatreName,
                    startDateTimeAsString);
            }

            return performanceOutput.ToString();
        }
Esempio n. 8
0
        public virtual ICommand CreateCommand(string commandName, IPerformanceDatabase performanceDatabase, IRenderer renderer)
        {
            ICommand command = null;

            switch (commandName.ToLower())
            {
            case "addperformance":
                command = new AddPerformanceCommand(performanceDatabase, renderer);
                break;

            case "addtheatre":
                command = new AddTheatreCommand(performanceDatabase, renderer);
                break;

            case "printallperformances":
                command = new PrintAllPerformancesCommand(performanceDatabase, renderer);
                break;

            case "printalltheatres":
                command = new PrintAllTheatresCommand(performanceDatabase, renderer);
                break;

            case "printperformances":
                command = new PrintPerformancesCommand(performanceDatabase, renderer);
                break;

            default:
                throw new ArgumentException("Invalid command!");
            }

            return(command);
        }
Esempio n. 9
0
        public void InitializeTest()
        {
            this.performances = new PerformanceDatabase();
            this.performances.AddTheatre("Theatre Sofia");
            this.performances.AddTheatre("Theatre 199");

            // Theatre 199, Duende, 20.01.2015 20:00, 1:30, 14.5
            this.performance1 = new Performance(
                "Theatre 199", 
                "Duende", 
                new DateTime(2015, 1, 19, 20, 0, 0), 
                new TimeSpan(0, 1, 30, 0), 
                14.5M);

            // Theatre 199, Bella Donna, 20.01.2015 20:30, 1:00, 12)
            this.performance2 = new Performance(
                "Theatre 199", 
                "Bella Donna", 
                new DateTime(2015, 1, 20, 20, 30, 0), 
                new TimeSpan(0, 1, 0, 0), 
                12.0M);

            // Theatre Sofia, Don Juan, 20.01.2015 20:31, 2:00, 14.60
            this.performance3 = new Performance(
                "Theatre Sofia", 
                "Don Juan", 
                new DateTime(2015, 1, 20, 20, 31, 0), 
                new TimeSpan(0, 2, 0, 0), 
                14.6M);
        }
Esempio n. 10
0
 public AppEngine(ICommandManager commandManager, IPerformanceDatabase performanceDatabase,
                  IRenderer renderer, IInputHandler inputHandler)
 {
     this.commandManager      = commandManager;
     this.PerformanceDatabase = performanceDatabase;
     this.renderer            = renderer;
     this.inputHandler        = inputHandler;
 }
Esempio n. 11
0
        public static string ExecuteAddPerformanceCommand(IPerformanceDatabase dataBase, AddPerformanceCommand command)
        {
            dataBase.AddPerformance(
                command.Theatre,
                command.Performance,
                command.Date,
                command.Duration,
                command.Price);

            return "Performance added";
        }
Esempio n. 12
0
        public static string ExecuteAddPerformanceCommand(string[] commandParams, IPerformanceDatabase database)
        {
            string theatreName = commandParams[0];
            string performanceTitle = commandParams[1];
            DateTime startDateTime = DateTime.ParseExact(commandParams[2],
                "dd.MM.yyyy HH:mm",
                CultureInfo.InvariantCulture);
            TimeSpan duration = TimeSpan.Parse(commandParams[3]);
            decimal price = decimal.Parse(commandParams[4], NumberStyles.Float);

            database.AddPerformance(theatreName,
                performanceTitle,
                startDateTime,
                duration,
                price);

            return "Performance added";
        }
Esempio n. 13
0
        public static string ExecutePrintPerformanceCommand(string[] commandParams, IPerformanceDatabase database)
        {
            string theatre = commandParams[0];
            var performances = database.ListOfPerformances(theatre)
                .Select(p => string.Format(
                    "({0}, {1})",
                    p.PerformanceTitle,
                    p.StartDateTime.ToString("dd.MM.yyyy HH:mm")))
                .ToList();

            if (performances.Any())
            {
                var result = string.Join(", ", performances);
                return result;
            }

            return "No performances";
        }
Esempio n. 14
0
        public static string ExecuteAddPerformanceCommand(string[] commandParams, IPerformanceDatabase database)
        {
            string   theatreName      = commandParams[0];
            string   performanceTitle = commandParams[1];
            DateTime startDateTime    = DateTime.ParseExact(commandParams[2],
                                                            "dd.MM.yyyy HH:mm",
                                                            CultureInfo.InvariantCulture);
            TimeSpan duration = TimeSpan.Parse(commandParams[3]);
            decimal  price    = decimal.Parse(commandParams[4], NumberStyles.Float);

            database.AddPerformance(theatreName,
                                    performanceTitle,
                                    startDateTime,
                                    duration,
                                    price);

            return("Performance added");
        }
Esempio n. 15
0
        public static string ExecutePrintPerformanceCommand(string[] commandParams, IPerformanceDatabase database)
        {
            string theatre      = commandParams[0];
            var    performances = database.ListOfPerformances(theatre)
                                  .Select(p => string.Format(
                                              "({0}, {1})",
                                              p.PerformanceTitle,
                                              p.StartDateTime.ToString("dd.MM.yyyy HH:mm")))
                                  .ToList();

            if (performances.Any())
            {
                var result = string.Join(", ", performances);
                return(result);
            }

            return("No performances");
        }
Esempio n. 16
0
        public static string ExecutePrintAllTheatresCommand(IPerformanceDatabase database)
        {
            var theatresCount = database.ListTheatres().Count();
            if (theatresCount > 0)
            {
                //var resultTheatres = new LinkedList<string>();
                //for (int i = 0; i < theatresCount; i++)
                //{
                //    database.ListTheatres().Skip(i).ToList().ForEach(t => resultTheatres.AddLast(t));
                //    foreach (var t in database.ListTheatres().Skip(i + 1))
                //    {
                //        resultTheatres.Remove(t);
                //    }
                //}
                return String.Join(", ", database.ListTheatres());
            }

            return "No theatres";
        }
        public static string ExecutePrintAllTheatresCommand(IPerformanceDatabase database)
        {
            var theatresCount = database.ListTheatres().Count();

            if (theatresCount == 0)
            {
                return "No theatres";
            }

            var resultTheatres = new LinkedList<string>();

            database.ListTheatres()
                    .ToList()
                    .ForEach(t => resultTheatres.AddLast(t));

            // PERFORMANCE: Useless iteration with foreach loop, which removes elements from Linkedlist
            // a slow operation
            return string.Join(", ", resultTheatres);
        }
Esempio n. 18
0
        public static string ExecutePrintAllTheatresCommand(IPerformanceDatabase database)
        {
            var theatresCount = database.ListTheatres().Count();

            if (theatresCount > 0)
            {
                //var resultTheatres = new LinkedList<string>();
                //for (int i = 0; i < theatresCount; i++)
                //{
                //    database.ListTheatres().Skip(i).ToList().ForEach(t => resultTheatres.AddLast(t));
                //    foreach (var t in database.ListTheatres().Skip(i + 1))
                //    {
                //        resultTheatres.Remove(t);
                //    }
                //}
                return(String.Join(", ", database.ListTheatres()));
            }

            return("No theatres");
        }
Esempio n. 19
0
        public static string ExecutePrintPerformancesCommand(IPerformanceDatabase dataBase,
            PrintPerformancesCommand command)
        {
            string result = String.Empty;
            var performances = dataBase.ListPerformances(command.TheatreName)
                            .Select(p =>
                            {
                                var result1 = p.Date.ToString("dd.MM.yyyy HH:mm");
                                return string.Format("({0}, {1})", p.PefrofmanceName, result1);
                            })
                            .ToList();

            if (performances.Any())
            {
                result = string.Join(", ", performances);
            }
            else
            {
                result = "No performances";
            }
            return result;
        }
 public PrintAllPerformancesCommand(string[] args, IPerformanceDatabase performanceDatabase)
     : base(args, performanceDatabase)
 {
 }
Esempio n. 21
0
 public Engine(IReader reader, IWriter writer, IPerformanceDatabase database)
 {
     this.reader = reader;
     this.writer = writer;
     this.database = database;
 }
 public CommandManager(IPerformanceDatabase performanceDatabas)
 {
     this.performanceDatabase = performanceDatabas;
 }
Esempio n. 23
0
 protected BaseCommand(string[] args, IPerformanceDatabase performanceDatabase)
 {
     this.CommandArgs = args;
     this.PerformanceDatabase = performanceDatabase;
 }
Esempio n. 24
0
 public void InitializeTest()
 {
     theatreDatabase = new PerformanceDatabase();
 }
Esempio n. 25
0
 protected AbstractCommand(IPerformanceDatabase performanceDatabase, IRenderer renderer)
 {
     this.PerformanceDatabase = performanceDatabase;
     this.Renderer            = renderer;
 }
 public void Initialize()
 {
     this.performanceDatabase = new PerformanceDatabase();
 }
 public AddPerformanceCommand(string[] args, IPerformanceDatabase performanceDatabase)
     : base(args, performanceDatabase)
 {
 }
 protected AbstractCommand(IPerformanceDatabase performanceDatabase)
 {
     this.performanceDatabase = performanceDatabase;
 }
Esempio n. 29
0
 public void SetUp()
 {
     this.data = new PerformanceDatabase();
 }
 public void InitializeTest()
 {
     this.database = new PerformanceDatabase();
 }
Esempio n. 31
0
 internal Engine(IPerformanceDatabase db, IInputMethod inputMethod, IOutputMethod outputMethod)
 {
     this.InputMethod = inputMethod;
     this.OutputMethod = outputMethod;
     this.DataBase = db;
 }
Esempio n. 32
0
 public string ExecuteAddTheaterCommand(IPerformanceDatabase performancesDatabase, string name)
 {
     performancesDatabase.AddTheater(name);
     return "Theatre added";
 }
 public void Inicialize_TestDatabase()
 {
     performanceDatabase = new PerformanceDatabase();
 }
Esempio n. 34
0
 public Engine(IPerformanceDatabase database, IInputReader reader, IOutputWriter writer)
 {
     this.database = database;
     this.reader = reader;
     this.writer = writer;
 }
Esempio n. 35
0
 public Engine(IReader reader, IWriter writer, IPerformanceDatabase database)
 {
     this.reader   = reader;
     this.writer   = writer;
     this.database = database;
 }
Esempio n. 36
0
 public void InitializeTest()
 {
     performanceDb = new PerformanceDatabase();
 }
 public AddPerformanceCommand(string[] inputArgs, IPerformanceDatabase performanceDatabase)
     : base(performanceDatabase)
 {
     this.parameters = inputArgs;
 }
Esempio n. 38
0
 public CommandExecutor(IPerformanceDatabase performanceDatabase)
 {
     this.performanceDatabase = performanceDatabase;
 }
Esempio n. 39
0
 public TheatreEngine()
 {
     this.theatreDatabase = new PerformanceDatabase();
 }
Esempio n. 40
0
 public PrintPerformancesCommand(IPerformanceDatabase performanceDatabase, IRenderer renderer)
     : base(performanceDatabase, renderer)
 {
 }
Esempio n. 41
0
 public AddTheatreCommand(IPerformanceDatabase performanceDatabase, IRenderer renderer)
     : base(performanceDatabase, renderer)
 {
 }
 public PrintAllTheatresCommand(IPerformanceDatabase performanceDatabase)
     : base(performanceDatabase)
 {
 }
 public void InitializeDb()
 {
     this.db = new TheatreDatabase();
 }
 public InvalidResultCommand(IPerformanceDatabase performanceDatabase)
     : base(null)
 {
 }
Esempio n. 45
0
 public Engine(IPerformanceDatabase database, IUserInterface userInterface)
 {
     this.database      = database;
     this.userInterface = userInterface;
 }
Esempio n. 46
0
 public CommandManager(IPerformanceDatabase database, IAppender appender)
 {
     this.database = database;
     this.appender = appender;
 }
 public CommandManager(IPerformanceDatabase database, IAppender appender, IReader reader)
 {
     this.Database = database;
     this.Appender = appender;
     this.Reader   = reader;
 }