Exemplo n.º 1
0
 public ActionResult LeagueGroups(int?fedSeason, string season, FormCollection collection)
 {
     try
     {
         int fedId = 0;
         if (fedSeason != null)
         {
             fedId = Convert.ToInt32(fedSeason);
         }
         else
         {
             season = collection[0].Split(',')[0];
             fedId  = Convert.ToInt32(collection[1]);
         }
         List <string>            group           = new List <string>();
         List <List <Score> >     score           = new List <List <Score> >();
         List <List <Standings> > standingsGroups = new ServiceDatabase().CreateModelStandingsGroups(fedId, ref score, season, ref group);
         ViewBag.Score = score;
         ViewBag.Group = group;
         return(View("LeagueGroups", standingsGroups.ToList()));
     }
     catch (Exception e)
     {
         ViewBag.Error = e.Message;
         return(View("Error"));
     }
 }
Exemplo n.º 2
0
 public ActionResult LeagueGroups(string sport, string fed, string tour, int?fedSeason)
 {
     try
     {
         if (fedSeason == null)
         {
             if (sport == null && fed == null && tour == null)
             {
                 sport = "Football";
                 fed   = "UEFA";
                 tour  = "League";
             }
             fedSeason = new ServiceDatabase().Find(sport, fed, tour);
         }
         List <string>            group           = new List <string>();
         List <List <Score> >     score           = new List <List <Score> >();
         List <List <Standings> > standingsGroups = new ServiceDatabase().CreateModelStandingsGroups(Convert.ToInt32(fedSeason), ref score, null, ref group);
         ViewBag.Score = score;
         ViewBag.Group = group;
         return(View("LeagueGroups", standingsGroups.ToList()));
     }
     catch (Exception e)
     {
         ViewBag.Error = e.Message;
         return(View("Error"));
     }
 }
Exemplo n.º 3
0
        public ActionResult Result(FormCollection collection)
        {
            try
            {
                string       season    = collection[0];
                int          tour      = Convert.ToInt32(collection[1]);
                int          fedSeason = Convert.ToInt32(collection[2]);
                int          countTour = 0;
                List <Score> result    = new ServiceDatabase().Result(ref countTour, fedSeason, season, tour);

                string[] array = new string[countTour];
                for (int i = 1; i <= countTour; i++)
                {
                    array[i - 1] = Convert.ToString(i);
                }
                ViewData["myList"] = new SelectList(array.Select(x => new { value = x, text = x }),
                                                    "value", "text", tour);
                return(View(result));
            }
            catch (Exception e)
            {
                ViewBag.Error = e.Message;
                return(View("Error"));
            }
        }
Exemplo n.º 4
0
 public ActionResult ProgressAway(int?fedSeason)
 {
     try
     {
         List <Progress> progresses = new ServiceDatabase().ProgressesAway(Convert.ToInt32(fedSeason));
         return(View("Progress", progresses));
     }
     catch (Exception e)
     {
         ViewBag.Error = e.Message;
         return(View("Error"));
     }
 }
Exemplo n.º 5
0
 public ActionResult Team(int?fedSeason, int?TeamId)
 {
     try
     {
         ShowTeam team = new ServiceDatabase().CreateModelsShowTeam(Convert.ToInt32(TeamId), Convert.ToInt32(fedSeason), null);
         return(View(team));
     }
     catch (Exception e)
     {
         ViewBag.Error = e.Message;
         return(View("Error"));
     }
 }
Exemplo n.º 6
0
 public ActionResult Search(string edit)
 {
     try
     {
         List <List <List <string> > > search = new ServiceDatabase().Search(edit);
         return(View("Search", search));
     }
     catch (Exception e)
     {
         ViewBag.Error = e.Message;
         return(View("Error"));
     }
 }
Exemplo n.º 7
0
 public ActionResult Winners(int?fedSeason)
 {
     try
     {
         List <Winner> Winners = new ServiceDatabase().Winners(Convert.ToInt32(fedSeason));
         return(View(Winners));
     }
     catch (Exception e)
     {
         ViewBag.Error = e.Message;
         return(View("Error"));
     }
 }
Exemplo n.º 8
0
 public ActionResult StandingsAway(int fedSeason)
 {
     try
     {
         List <Standings> standings = new ServiceDatabase().CreateModelStandingsAway(fedSeason);
         return(View("Standings", standings.ToList()));
     }
     catch (Exception e)
     {
         ViewBag.Error = e.Message;
         return(View("Error"));
     }
 }
Exemplo n.º 9
0
 public ActionResult Standings(string sport, string fed, string tour, int?fedSeason)
 {
     try
     {
         List <Standings> standings  = new ServiceDatabase().CreateModelStandings(sport, fed, tour, fedSeason);
         List <Standings> SortedList = standings.OrderByDescending(o => o.Point).ToList();
         return(View(SortedList.ToList()));
     }
     catch (Exception e)
     {
         ViewBag.Error = myException.Message + " " + e.Message;
         return(View("Error"));
     }
 }
Exemplo n.º 10
0
 public ActionResult Scorers(int?fedSeason, FormCollection collection)
 {
     try
     {
         fedSeason = Convert.ToInt32(collection[1]);
         string        season  = collection[0];
         List <Scorer> scorers = new ServiceDatabase().Scorers(fedSeason, season);
         return(View(scorers));
     }
     catch (Exception e)
     {
         ViewBag.Error = e.Message;
         return(View("Error"));
     }
 }
Exemplo n.º 11
0
 public ActionResult Team(FormCollection collection)
 {
     try
     {
         int      TeamId    = Convert.ToInt32(collection[2]);
         int      fedSeason = Convert.ToInt32(collection[1]);
         string   season    = collection[0];
         ShowTeam team      = new ServiceDatabase().CreateModelsShowTeam(TeamId, fedSeason, season);
         return(View(team));
     }
     catch (Exception e)
     {
         ViewBag.Error = e.Message;
         return(View("Error"));
     }
 }
Exemplo n.º 12
0
 public ActionResult Player(FormCollection collection)
 {
     try
     {
         int        PlayerId  = Convert.ToInt32(collection[2]);
         int        fedSeason = Convert.ToInt32(collection[1]);
         string     season    = collection[0];
         ShowPlayer player    = new ServiceDatabase().ShowPlayer(fedSeason, PlayerId, season);
         return(View(player));
     }
     catch (Exception e)
     {
         ViewBag.Error = e.Message;
         return(View("Error"));
     }
 }
Exemplo n.º 13
0
 public ActionResult Standings(FormCollection collection)
 {
     try
     {
         int              fedSeason  = Convert.ToInt32(collection[1]);
         string           season     = collection[0];
         List <Standings> standings  = new ServiceDatabase().CreateModelStandings(null, null, season, fedSeason);
         List <Standings> SortedList = standings.OrderByDescending(o => o.Point).ToList();
         return(View(SortedList.ToList()));
     }
     catch (Exception e)
     {
         ViewBag.Error = e.Message;
         return(View("Error"));
     }
 }
Exemplo n.º 14
0
 public ActionResult Match(int?MatchId)
 {
     try
     {
         ShowMatch Match = new ShowMatch();
         if (MatchId != null)
         {
             Match = new ServiceDatabase().ShowMatch(Convert.ToInt32(MatchId));
         }
         return(View(Match));
     }
     catch (Exception e)
     {
         ViewBag.Error = e.Message;
         return(View("Error"));
     }
 }
Exemplo n.º 15
0
        public ActionResult Player(int?fedSeason, int?PlayerId)
        {
            try
            {
                ShowPlayer player = new ShowPlayer();
                if (fedSeason != null && PlayerId != null)
                {
                    player = new ServiceDatabase().ShowPlayer(Convert.ToInt32(fedSeason), Convert.ToInt32(PlayerId), null);
                }

                return(View(player));
            }
            catch (Exception e)
            {
                ViewBag.Error = e.Message;
                return(View("Error"));
            }
        }
Exemplo n.º 16
0
 public ActionResult ArchScorers(int?fedSeason)
 {
     try
     {
         List <Scorer> scorers = new List <Scorer>();
         if (fedSeason == null)
         {
             scorers = new ServiceDatabase().ArchScorers(10);
         }
         else
         {
             scorers = new ServiceDatabase().ArchScorers(Convert.ToInt32(fedSeason));
         }
         return(View(scorers));
     }
     catch (Exception e)
     {
         ViewBag.Error = e.Message;
         return(View("Error"));
     }
 }
Exemplo n.º 17
0
 public ActionResult Scorers(int?fedSeason)
 {
     try
     {
         string season = null;
         if (fedSeason == null)
         {
             if (Request.Cookies["Id"] != null)
             {
                 fedSeason = Convert.ToInt32(Request.Cookies["Id"].Value);
                 Response.Cookies["Id"].Expires = DateTime.Now.AddDays(-1);
             }
         }
         List <Scorer> scorers = new ServiceDatabase().Scorers(fedSeason, season);
         return(View(scorers));
     }
     catch (Exception e)
     {
         ViewBag.Error = e.Message;
         return(View("Error"));
     }
 }
Exemplo n.º 18
0
        public void Existing_Database_Test()
        {
            ServiceDatabase sBase = new ServiceDatabase();

            Assert.AreEqual("1110000\n1210000\n1310000\n1410000\n1610000\n1510000\n1810000\n", sBase.printServices(ServiceTypes.Donate));
            Assert.AreEqual("2110000\n", sBase.printServices(ServiceTypes.Drive));
            Assert.AreEqual("3110000\n3210000\n3310000\n", sBase.printServices(ServiceTypes.Educate));
            Assert.AreEqual("4110000\n", sBase.printServices(ServiceTypes.Request));

            Assert.AreEqual("1110000\n", sBase.printServices(ServiceTypes.Donate, DonationTypes.Toys));
            Assert.AreEqual("1210000\n", sBase.printServices(ServiceTypes.Donate, DonationTypes.Clothes));
            Assert.AreEqual("1310000\n", sBase.printServices(ServiceTypes.Donate, DonationTypes.Tech));
            Assert.AreEqual("1410000\n", sBase.printServices(ServiceTypes.Donate, DonationTypes.FirstAid));
            Assert.AreEqual("1510000\n", sBase.printServices(ServiceTypes.Donate, DonationTypes.Hygene));
            Assert.AreEqual("1610000\n", sBase.printServices(ServiceTypes.Donate, DonationTypes.Food));
            Assert.AreEqual("1810000\n", sBase.printServices(ServiceTypes.Donate, DonationTypes.Other));

            Assert.AreEqual("2110000\n", sBase.printServices(ServiceTypes.Drive, DonationTypes.Goods));

            Assert.AreEqual("3110000\n", sBase.printServices(ServiceTypes.Educate, DonationTypes.Math));
            Assert.AreEqual("3210000\n", sBase.printServices(ServiceTypes.Educate, DonationTypes.Reading));
            Assert.AreEqual("3310000\n", sBase.printServices(ServiceTypes.Educate, DonationTypes.Writing));

            Assert.AreEqual("4110000\n", sBase.printServices(ServiceTypes.Request, DonationTypes.Donation));

            Service toy = sBase.retrieveService("1110000");

            Assert.AreEqual(toy, sBase.retrieveService("1110000"));
            Service clothes = sBase.retrieveService("1210000");

            Assert.AreEqual(clothes, sBase.retrieveService("1210000"));
            Service tech = sBase.retrieveService("1310000");

            Assert.AreEqual(tech, sBase.retrieveService("1310000"));
            Service faid = sBase.retrieveService("1410000");

            Assert.AreEqual(faid, sBase.retrieveService("1410000"));
            Service hygiene = sBase.retrieveService("1510000");

            Assert.AreEqual(hygiene, sBase.retrieveService("1510000"));
            Service food = sBase.retrieveService("1610000");

            Assert.AreEqual(food, sBase.retrieveService("1610000"));
            Service other = sBase.retrieveService("1810000");

            Assert.AreEqual(other, sBase.retrieveService("1810000"));

            Service drive = sBase.retrieveService("2110000");

            Assert.AreEqual(drive, sBase.retrieveService("2110000"));

            Service math = sBase.retrieveService("3110000");

            Assert.AreEqual(math, sBase.retrieveService("3110000"));
            Service read = sBase.retrieveService("3210000");

            Assert.AreEqual(read, sBase.retrieveService("3210000"));
            Service write = sBase.retrieveService("3310000");

            Assert.AreEqual(write, sBase.retrieveService("3310000"));

            Service request = sBase.retrieveService("4110000");

            Assert.AreEqual(request, sBase.retrieveService("4110000"));

            string path = @"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow";

            File.Delete(Path.Combine(path, "Toy_Dictionary.txt"));
            File.Delete(Path.Combine(path, "Clothes_Dictionary.txt"));
            File.Delete(Path.Combine(path, "Tech_Dictionary.txt"));
            File.Delete(Path.Combine(path, "FirstAid_Dictionary.txt"));
            File.Delete(Path.Combine(path, "Hygene_Dictionary.txt"));
            File.Delete(Path.Combine(path, "Food_Dictionary.txt"));
            File.Delete(Path.Combine(path, "Other_Dictionary.txt"));

            File.Delete(Path.Combine(path, "Goods_Dictionary.txt"));

            File.Delete(Path.Combine(path, "Math_Dictionary.txt"));
            File.Delete(Path.Combine(path, "Reading_Dictionary.txt"));
            File.Delete(Path.Combine(path, "Writing_Dictionary.txt"));

            File.Delete(Path.Combine(path, "Donation_Dictionary.txt"));

            File.Delete(Path.Combine(path, "serial_list.txt"));
            File.Delete(Path.Combine(path, "userlist.txt"));
        }
Exemplo n.º 19
0
        public ActionResult Stub(string stub)
        {
            List <string> list = new ServiceDatabase().Stub(stub);

            return(View(list));
        }
Exemplo n.º 20
0
        public void Service_Database_Test()
        {
            ServiceDatabase sBase    = new ServiceDatabase();
            UserDatabase    uBase    = new UserDatabase();;
            User            testUser = new User("Tester", "Password", "*****@*****.**", "123 Test St.", null, "Tacoma", "WA", "98422");

            uBase.addUser(testUser);
            uBase.deleteUser(testUser.getEmail());
            Service toy     = new Service("Tester", "*****@*****.**");
            Service clothes = new Service("Tester", "*****@*****.**");
            Service faid    = new Service("Tester", "*****@*****.**");
            Service hygiene = new Service("Tester", "*****@*****.**");
            Service tech    = new Service("Tester", "*****@*****.**");
            Service food    = new Service("Tester", "*****@*****.**");
            Service other   = new Service("Tester", "*****@*****.**");

            Service drive = new Service("Tester", "*****@*****.**");

            Service math  = new Service("Tester", "*****@*****.**");
            Service read  = new Service("Tester", "*****@*****.**");
            Service write = new Service("Tester", "*****@*****.**");

            Service request = new Service("Tester", "*****@*****.**");

            sBase.createService(ServiceTypes.Donate, DonationTypes.Toys, testUser, toy);
            sBase.createService(ServiceTypes.Donate, DonationTypes.Clothes, testUser, clothes);
            sBase.createService(ServiceTypes.Donate, DonationTypes.Tech, testUser, tech);
            sBase.createService(ServiceTypes.Donate, DonationTypes.FirstAid, testUser, faid);
            sBase.createService(ServiceTypes.Donate, DonationTypes.Food, testUser, food);
            sBase.createService(ServiceTypes.Donate, DonationTypes.Hygene, testUser, hygiene);
            sBase.createService(ServiceTypes.Donate, DonationTypes.Other, testUser, other);

            sBase.createService(ServiceTypes.Drive, DonationTypes.Goods, testUser, drive);

            sBase.createService(ServiceTypes.Educate, DonationTypes.Math, testUser, math);
            sBase.createService(ServiceTypes.Educate, DonationTypes.Reading, testUser, read);
            sBase.createService(ServiceTypes.Educate, DonationTypes.Writing, testUser, write);

            sBase.createService(ServiceTypes.Request, DonationTypes.Tools, testUser, request);

            Assert.AreEqual("1110000\n1210000\n1310000\n1410000\n1610000\n1510000\n1810000\n", sBase.printServices(ServiceTypes.Donate));
            Assert.AreEqual("2110000\n", sBase.printServices(ServiceTypes.Drive));
            System.Console.WriteLine(sBase.retrieveService("3210000"));
            Assert.AreEqual("3110000\n3210000\n3310000\n", sBase.printServices(ServiceTypes.Educate));
            Assert.AreEqual("4110000\n", sBase.printServices(ServiceTypes.Request));

            Assert.AreEqual("1110000\n", sBase.printServices(ServiceTypes.Donate, DonationTypes.Toys));
            Assert.AreEqual("1210000\n", sBase.printServices(ServiceTypes.Donate, DonationTypes.Clothes));
            Assert.AreEqual("1310000\n", sBase.printServices(ServiceTypes.Donate, DonationTypes.Tech));
            Assert.AreEqual("1410000\n", sBase.printServices(ServiceTypes.Donate, DonationTypes.FirstAid));
            Assert.AreEqual("1510000\n", sBase.printServices(ServiceTypes.Donate, DonationTypes.Hygene));
            Assert.AreEqual("1610000\n", sBase.printServices(ServiceTypes.Donate, DonationTypes.Food));
            Assert.AreEqual("1810000\n", sBase.printServices(ServiceTypes.Donate, DonationTypes.Other));

            Assert.AreEqual("2110000\n", sBase.printServices(ServiceTypes.Drive, DonationTypes.Goods));

            Assert.AreEqual("3110000\n", sBase.printServices(ServiceTypes.Educate, DonationTypes.Math));
            Assert.AreEqual("3210000\n", sBase.printServices(ServiceTypes.Educate, DonationTypes.Reading));
            Assert.AreEqual("3310000\n", sBase.printServices(ServiceTypes.Educate, DonationTypes.Writing));

            Assert.AreEqual("4110000\n", sBase.printServices(ServiceTypes.Request, DonationTypes.Donation));

            Assert.AreEqual(toy, sBase.retrieveService("1110000"));
            Assert.AreEqual(clothes, sBase.retrieveService("1210000"));
            Assert.AreEqual(tech, sBase.retrieveService("1310000"));
            Assert.AreEqual(faid, sBase.retrieveService("1410000"));
            Assert.AreEqual(hygiene, sBase.retrieveService("1510000"));
            Assert.AreEqual(food, sBase.retrieveService("1610000"));
            Assert.AreEqual(other, sBase.retrieveService("1810000"));

            Assert.AreEqual(drive, sBase.retrieveService("2110000"));

            Assert.AreEqual(math, sBase.retrieveService("3110000"));
            Assert.AreEqual(read, sBase.retrieveService("3210000"));
            Assert.AreEqual(write, sBase.retrieveService("3310000"));

            Assert.AreEqual(request, sBase.retrieveService("4110000"));
        }
Exemplo n.º 21
0
 public ServiceDatabaseTest()
 {
     _sut = new ServiceDatabase(_mongoClientMock.Object);
 }
Exemplo n.º 22
0
        public void User_Setter_Getter_Test()
        {
            User            test  = new User(name, password, email, street, apartment, city, state, zipcode);
            UserDatabase    uBase = new UserDatabase();
            ServiceDatabase sBase = new ServiceDatabase();

            uBase.addUser(test);

            test.setName("tester");
            Assert.AreEqual("tester", test.getName());
            test.setPassword("pass");
            Assert.IsTrue(uBase.verifyUser("*****@*****.**", "pass"));
            test.setEmail("*****@*****.**");
            Assert.AreEqual("*****@*****.**", test.getEmail());
            test.setAddress("321 Test St", "#201", "Portland", "OR", "97501");
            Assert.AreEqual("321 Test St, #201, Portland, OR, 97501", test.getAddress());
            test.setVehicleType("Sedan");
            Assert.AreEqual("Sedan", test.getVehicleType());
            test.setCapacity("30");
            Assert.AreEqual("30", test.getCapacity());
            test.setTimeStart("1400");
            Assert.AreEqual("1400", test.getTimeStart());
            test.setTimeStop("2000");
            Assert.AreEqual("2000", test.getTimeStop());
            test.setLicenseFilePath("testing.jpeg");
            Assert.AreEqual("testing.jpeg", test.getLicenseFilePath());
            test.setAdmin(true);
            Assert.IsTrue(test.isAdmin());

            Service toy = new Service("tester", "*****@*****.**");

            sBase.createService(ServiceTypes.Donate, DonationTypes.Toys, test, toy);
            myServices = new List <Service>();
            myServices.Add(toy);
            test.addService(toy);
            Assert.AreEqual(myServices[0], test.getServices()[0]);

            Assert.IsTrue(test.checkPassword("pass"));
            Assert.IsFalse(test.checkPassword("Password"));

            test.addDrive(vehichle, capacity, start, stop, license);
            Assert.AreEqual(vehichle, test.getVehicleType());
            Assert.AreEqual(capacity, test.getCapacity());
            Assert.AreEqual(start, test.getTimeStart());
            Assert.AreEqual(stop, test.getTimeStop());
            Assert.AreEqual(license, test.getLicenseFilePath());

            string path = @"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow";

            File.Delete(Path.Combine(path, "Toy_Dictionary.txt"));
            File.Delete(Path.Combine(path, "Clothes_Dictionary.txt"));
            File.Delete(Path.Combine(path, "Tech_Dictionary.txt"));
            File.Delete(Path.Combine(path, "First_Aid_Dictionary.txt"));
            File.Delete(Path.Combine(path, "Hygene_Dictionary.txt"));
            File.Delete(Path.Combine(path, "Food_Dictionary.txt"));
            File.Delete(Path.Combine(path, "Other_Dictionary.txt"));

            File.Delete(Path.Combine(path, "Goods_Dictionary.txt"));

            File.Delete(Path.Combine(path, "Math_Dictionary.txt"));
            File.Delete(Path.Combine(path, "Reading_Dictionary.txt"));
            File.Delete(Path.Combine(path, "Writing_Dictionary.txt"));

            File.Delete(Path.Combine(path, "Request_Dictionary.txt"));

            File.Delete(Path.Combine(path, "serial_list.txt"));
            File.Delete(Path.Combine(path, "userlist.txt"));
        }