Beispiel #1
0
        public void TestAddLineupDeleteLineup()
        {
            WebClient wc = WebClient.getInstance();

            TokenRequest tr = new TokenRequest();

            tr.username = username;
            tr.password = password;

            AlterLineupsResponse alr = wc.addLineup(tr, "/20141201/lineups/CAN-0005410-X");

            Assert.NotNull(alr);

            Assert.AreEqual(0, alr.code);

            List <AssignedLineupsResponse.Lineup> alrl = wc.getAssignedLineups(tr);

            Assert.NotNull(alrl);

            Assert.AreEqual(1, alrl.Count);

//			alr = wc.deleteLineup(tr, "/20141201/lineups/CAN-0005410-X");
//			Assert.NotNull(alr);
//
//			Assert.AreEqual(0, alr.code);
        }
Beispiel #2
0
        /// <summary>
        /// remove a lineup from being assigned to a user
        /// </summary>
        /// <param name="tr"></param>
        /// <param name="lineupRelativeUrl"></param>
        /// <returns></returns>
        public AlterLineupsResponse deleteLineup(TokenRequest tr, string lineupRelativeUrl)
        {
            AlterLineupsResponse alr = new AlterLineupsResponse();

            string token = getToken(tr);

            // assuming lineupRelativeUrl starts with /
            string url = baseUrlWithoutVersion + lineupRelativeUrl;

            alr = executeHttpRequest <AlterLineupsResponse>(token, "DELETE", url);

            if (alr.code != 0)
            {
                Logger.Error("Unable to delete lineup: {0}", alr.message);
            }
            else
            {
                Logger.Info("Lineup Removed");
            }

            return(alr);
        }
Beispiel #3
0
        void SaveLineupsButtonClick(object sender, EventArgs e)
        {
            //
            this.saveButton.Enabled = false;

            // get currently assigned lineups
            WebClient wc = WebClient.getInstance();

            TokenRequest tr = new TokenRequest(ConfigInstance.Current.SDUserName, ConfigInstance.Current.SDPassword);
            List <AssignedLineupsResponse.Lineup> assignedLineups = wc.getAssignedLineups(tr);

            List <string> lineupsToAssign = new List <string>();
            List <string> lineupsToDelete = new List <string>();


            // find lineups that were added
            foreach (object i in this.allLineupsList.SelectedItems)
            {
                LineupFactory.GuiLineup lu = (LineupFactory.GuiLineup)i;

                bool skipAdd = false;
                foreach (AssignedLineupsResponse.Lineup alu in assignedLineups)
                {
                    if (alu.uri.Equals(lu.uri))
                    {
                        skipAdd = true;
                        break;
                    }
                }

                if (!skipAdd)
                {
                    lineupsToAssign.Add(lu.uri);
                }
            }

            // find lineups that were deleted
            foreach (AssignedLineupsResponse.Lineup alu in assignedLineups)
            {
                bool skipDelete = false;
                foreach (object i in this.allLineupsList.SelectedItems)
                {
                    LineupFactory.GuiLineup lu = (LineupFactory.GuiLineup)i;

                    if (lu.uri.Equals(alu.uri))
                    {
                        // assigned lineup is still selected
                        skipDelete = true;
                        break;
                    }
                }

                if (!skipDelete)
                {
                    lineupsToDelete.Add(alu.uri);
                }
            }

            // add the lineups that need adding
            foreach (string uriToAdd in lineupsToAssign)
            {
                AlterLineupsResponse alr = wc.addLineup(tr, uriToAdd);

                this.addsLeftValueLabel.Text = alr.changesRemaining.ToString();
                this.addsLeftValueLabel.Refresh();
            }

            // delete the lineups that need deleting
            foreach (string uriToAdd in lineupsToDelete)
            {
                AlterLineupsResponse alr = wc.deleteLineup(tr, uriToAdd);

                this.addsLeftValueLabel.Text = alr.changesRemaining.ToString();
                this.addsLeftValueLabel.Refresh();
            }

            this.saveButton.Enabled = true;
        }