コード例 #1
0
        public string Get([FromQuery(Name = "token")] string token, string identifier)
        {
            try {
                TaskManager     taskManager = new TaskManager(Server.TeamServer.ObjectManager, Server.TeamServer.TokenIssuer.ElevateToken(token));
                Model.Task.Task task        = taskManager.LookupTask(identifier);

                return(ControllerUtils.SerializeObject(task, new List <string>(new string[] { "Identifier", "Which", "What", "When", "Active" })));
            }
            catch (Exception exception) {
                return("Error: " + exception.Message);
            }
        }
コード例 #2
0
        public string Get([FromQuery(Name = "token")] string token, string identifier)
        {
            try {
                TeamManager teamManager = new TeamManager(Server.TeamServer.ObjectManager, Server.TeamServer.TokenIssuer.ValidateToken(token));
                Team        team        = teamManager.LookupTeam(identifier);

                return(ControllerUtils.SerializeObject(team, new List <string>(new string[] { "Identifier", "Name" })));
            }
            catch (Exception exception) {
                return("Error: " + exception.Message);
            }
        }
コード例 #3
0
        public string Get([FromQuery(Name = "token")] string token, string identifier)
        {
            try {
                AccountManager accountManager = new AccountManager(Server.TeamServer.ObjectManager, Server.TeamServer.TokenIssuer.ElevateToken(token));
                Account        account        = accountManager.LookupAccount(identifier);

                return(ControllerUtils.SerializeObject(account, new List <string>(new string[] { "Identifier", "Name", "EMail", "Virgin", "Contract", "ContractMinutes", "AvailableMinutes" })));
            }
            catch (Exception exception) {
                return("Error: " + exception.Message);
            }
        }
コード例 #4
0
        public string Get([FromQuery(Name = "token")] string token, string identifier)
        {
            try {
                SessionManager sessionManager = new SessionManager(Server.TeamServer.ObjectManager, Server.TeamServer.TokenIssuer.ValidateToken(token));
                Lap            lap            = sessionManager.LookupLap(identifier);

                return(ControllerUtils.SerializeObject(lap, new List <string>(new string[] { "Identifier", "Nr" })));
            }
            catch (Exception exception) {
                return("Error: " + exception.Message);
            }
        }
コード例 #5
0
        public string Get([FromQuery(Name = "token")] string token, string identifier)
        {
            try {
                SessionManager sessionManager = new SessionManager(Server.TeamServer.ObjectManager, Server.TeamServer.TokenIssuer.ValidateToken(token));
                Session        session        = sessionManager.LookupSession(identifier);

                return(ControllerUtils.SerializeObject(session, new List <string>(new string[] { "Identifier", "Name", "Duration", "Started", "Finished", "Car", "Track" })));
            }
            catch (Exception exception) {
                return("Error: " + exception.Message);
            }
        }
コード例 #6
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);
            }
        }
コード例 #7
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);
            }
        }
コード例 #8
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);
            }
        }
コード例 #9
0
        public string Put([FromQuery(Name = "token")] string token, string identifier, [FromBody] string keyValues)
        {
            try {
                TeamManager teamManager = new TeamManager(Server.TeamServer.ObjectManager, Server.TeamServer.TokenIssuer.ValidateToken(token));
                Team        team        = teamManager.LookupTeam(identifier);

                ControllerUtils.DeserializeObject(team, keyValues);

                team.Save();

                return("Ok");
            }
            catch (Exception exception) {
                return("Error: " + exception.Message);
            }
        }
コード例 #10
0
        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);
            }
        }
コード例 #11
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);
            }
        }
コード例 #12
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);
            }
        }
コード例 #13
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);
            }
        }
コード例 #14
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);
            }
        }
コード例 #15
0
        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);
            }
        }