Exemple #1
0
        public string Post([FromQuery(Name = "token")] string token, [FromBody] string keyValues)
        {
            try {
                Token       theToken    = Server.TeamServer.TokenIssuer.ValidateToken(token);
                TeamManager teamManager = new TeamManager(Server.TeamServer.ObjectManager, theToken);

                Dictionary <string, string> properties = ControllerUtils.ParseKeyValues(keyValues);

                return(teamManager.CreateTeam(theToken.Account, properties["Name"]).Identifier.ToString());
            }
            catch (Exception exception) {
                return("Error: " + exception.Message);
            }
        }
Exemple #2
0
        public string Post([FromQuery(Name = "token")] string token, [FromQuery(Name = "stint")] string stint, [FromBody] string keyValues)
        {
            try {
                Token          theToken       = Server.TeamServer.TokenIssuer.ValidateToken(token);
                SessionManager sessionManager = new SessionManager(Server.TeamServer.ObjectManager, theToken);
                Stint          theStint       = sessionManager.LookupStint(stint);

                Dictionary <string, string> properties = ControllerUtils.ParseKeyValues(keyValues);

                return(sessionManager.CreateLap(theStint, lap: Int32.Parse(properties["Nr"])).Identifier.ToString());
            }
            catch (Exception exception) {
                return("Error: " + exception.Message);
            }
        }
Exemple #3
0
        public string Post([FromQuery(Name = "token")] string token, [FromQuery(Name = "team")] string team, [FromBody] string keyValues)
        {
            try {
                Token          theToken       = Server.TeamServer.TokenIssuer.ValidateToken(token);
                Team           theTeam        = new TeamManager(Server.TeamServer.ObjectManager, theToken).LookupTeam(team);
                SessionManager sessionManager = new SessionManager(Server.TeamServer.ObjectManager, theToken);

                Dictionary <string, string> properties = ControllerUtils.ParseKeyValues(keyValues);

                return(sessionManager.CreateSession(theTeam, properties.GetValueOrDefault <string, string>("Name", "Unknown")).Identifier.ToString());
            }
            catch (Exception exception) {
                return("Error: " + exception.Message);
            }
        }
        public string Post([FromQuery(Name = "token")] string token, [FromBody] string keyValues)
        {
            try {
                TaskManager taskManager = new TaskManager(Server.TeamServer.ObjectManager, Server.TeamServer.TokenIssuer.ElevateToken(token));

                Dictionary <string, string> properties = ControllerUtils.ParseKeyValues(keyValues);

                Model.Task.Task task = taskManager.CreateTask((Model.Task.Task.Type)Enum.Parse(typeof(Model.Task.Task.Type), properties["Which"]),
                                                              (Model.Task.Task.Operation)Enum.Parse(typeof(Model.Task.Task.Operation), properties["What"]),
                                                              (Model.Task.Task.Frequency)Enum.Parse(typeof(Model.Task.Task.Frequency), properties["When"]));

                return(task.Identifier.ToString());
            }
            catch (Exception exception) {
                return("Error: " + exception.Message);
            }
        }
Exemple #5
0
        public string ChangeContract([FromQuery(Name = "token")] string token, string identifier, [FromBody] string keyValues)
        {
            try {
                AccountManager accountManager = new AccountManager(Server.TeamServer.ObjectManager, Server.TeamServer.TokenIssuer.ElevateToken(token));
                Account        account        = accountManager.LookupAccount(identifier);

                Dictionary <string, string> properties = ControllerUtils.ParseKeyValues(keyValues);

                accountManager.ChangeContract(account, (Account.ContractType)Enum.Parse(typeof(Account.ContractType), properties["Contract"]),
                                              Int32.Parse(properties["ContractMinutes"]));

                account.Save();

                return("Ok");
            }
            catch (Exception exception) {
                return("Error: " + exception.Message);
            }
        }
Exemple #6
0
        public string StartSession([FromQuery(Name = "token")] string token, string identifier,
                                   [FromBody] string keyValues)
        {
            try {
                SessionManager sessionManager = new SessionManager(Server.TeamServer.ObjectManager, Server.TeamServer.TokenIssuer.ValidateToken(token));

                Dictionary <string, string> properties = ControllerUtils.ParseKeyValues(keyValues);

                sessionManager.StartSession(identifier,
                                            duration: Int32.Parse(properties["Duration"]),
                                            car: properties.GetValueOrDefault <string, string>("Car", "Unknown"),
                                            track: properties.GetValueOrDefault <string, string>("Track", "Unknown"));

                return("Ok");
            }
            catch (Exception exception) {
                return("Error: " + exception.Message);
            }
        }
Exemple #7
0
        public string Post([FromQuery(Name = "token")] string token, [FromBody] string keyValues)
        {
            try {
                AccountManager accountManager = new AccountManager(Server.TeamServer.ObjectManager, Server.TeamServer.TokenIssuer.ElevateToken(token));

                Dictionary <string, string> properties = ControllerUtils.ParseKeyValues(keyValues);

                Account account = accountManager.CreateAccount(properties["Name"]);

                if (properties.ContainsKey("EMail"))
                {
                    account.EMail = properties["EMail"];
                }

                if (properties.ContainsKey("Password"))
                {
                    account.Password = properties["Password"];
                }

                if (properties.ContainsKey("Contract"))
                {
                    account.Contract = (Account.ContractType)Enum.Parse(typeof(Account.ContractType), properties["Contract"]);
                }

                if (properties.ContainsKey("ContractMinutes"))
                {
                    account.ContractMinutes = Int32.Parse(properties["ContractMinutes"]);
                }

                if (properties.ContainsKey("AvailableMinutes"))
                {
                    account.AvailableMinutes = Int32.Parse(properties["AvailableMinutes"]);
                }

                account.Save();

                return(account.Identifier.ToString());
            }
            catch (Exception exception) {
                return("Error: " + exception.Message);
            }
        }
Exemple #8
0
        public string Put([FromQuery(Name = "token")] string token, string identifier, [FromBody] string keyValues)
        {
            try {
                AccountManager accountManager = new AccountManager(Server.TeamServer.ObjectManager, Server.TeamServer.TokenIssuer.ElevateToken(token));
                Account        account        = accountManager.LookupAccount(identifier);

                Dictionary <string, string> properties = ControllerUtils.ParseKeyValues(keyValues);

                if (properties.ContainsKey("EMail"))
                {
                    account.EMail = properties["EMail"];

                    account.Save().Wait();
                }

                if (properties.ContainsKey("Password"))
                {
                    accountManager.ChangePassword(account, properties["Password"]);
                }

                if (properties.ContainsKey("Contract"))
                {
                    accountManager.ChangeContract(account, (Account.ContractType)Enum.Parse(typeof(Account.ContractType), properties["Contract"]),
                                                  Int32.Parse(properties["ContractMinutes"]));
                }

                if (properties.ContainsKey("AvailableMinutes"))
                {
                    accountManager.SetMinutes(account, Int32.Parse(properties["AvailableMinutes"]));
                }

                return("Ok");
            }
            catch (Exception exception) {
                return("Error: " + exception.Message);
            }
        }
        public string Put([FromQuery(Name = "token")] string token, string identifier, [FromBody] string keyValues)
        {
            try {
                TaskManager     taskManager = new TaskManager(Server.TeamServer.ObjectManager, Server.TeamServer.TokenIssuer.ElevateToken(token));
                Model.Task.Task task        = taskManager.LookupTask(identifier);

                Dictionary <string, string> properties = ControllerUtils.ParseKeyValues(keyValues);

                if (properties.ContainsKey("Which"))
                {
                    task.Which = (Model.Task.Task.Type)Enum.Parse(typeof(Model.Task.Task.Type), properties["Which"]);
                }

                if (properties.ContainsKey("What"))
                {
                    task.What = (Model.Task.Task.Operation)Enum.Parse(typeof(Model.Task.Task.Operation), properties["What"]);
                }

                if (properties.ContainsKey("When"))
                {
                    task.When = (Model.Task.Task.Frequency)Enum.Parse(typeof(Model.Task.Task.Frequency), properties["When"]);
                }

                if (properties.ContainsKey("Active"))
                {
                    task.Active = (properties["Active"] == "true");
                }

                task.Save();

                return("Ok");
            }
            catch (Exception exception) {
                return("Error: " + exception.Message);
            }
        }