Beispiel #1
0
 public List <Sport> GetTableSports()
 {
     using (MatchDBContext db = new MatchDBContext())
     {
         return(db.Sports.ToList());
     }
 }
Beispiel #2
0
 public List <Match> GetTableMatches()
 {
     using (MatchDBContext db = new MatchDBContext())
     {
         return(db.Matches.ToList());
     }
 }
Beispiel #3
0
 public List <Odd> GetTableOdds()
 {
     using (MatchDBContext db = new MatchDBContext())
     {
         return(db.Odds.ToList());
     }
 }
Beispiel #4
0
        public ActionResult Index()
        {
            List <object> MultyList = new List <object>();



            using (MatchDBContext db = new MatchDBContext())
            {
                try
                {
                    //db.Database.Delete();

                    //NewFilter newFilter = new NewFilter();
                    //newFilter.DataImport();
                    NotificationEvents NE = new NotificationEvents();


                    MultyList.Add(db.Sports.ToList());
                    MultyList.Add(db.Events.ToList());
                    MultyList.Add(db.Matches.ToList());
                    MultyList.Add(db.Bets.ToList());
                    MultyList.Add(db.Odds.ToList());
                }catch { }


                return(View(MultyList));
            }
        }
Beispiel #5
0
        public void DeleteOldItems()
        {
            //Delete old Matches
            using (MatchDBContext db = new MatchDBContext())
            {
                foreach (var itemMatch in from c in db.Matches where c.StartDate < date select c)
                {
                    db.Matches.Remove(itemMatch);


                    foreach (var itemBet in from c in db.Bets where c.Match_ID == itemMatch.Id select c)
                    {
                        db.Bets.Remove(itemBet);



                        foreach (var itemOdd in from c in db.Odds where c.Bet_ID == itemBet.Id select c)
                        {
                            db.Odds.Remove(itemOdd);
                        }
                    }
                }
                try
                {
                    db.SaveChanges();
                }
                catch { }
            }
        }
Beispiel #6
0
 public List <Bet> GetTableBets()
 {
     using (MatchDBContext db = new MatchDBContext())
     {
         return(db.Bets.ToList());
     }
 }
Beispiel #7
0
 public List <Event> GetSportEv()
 {
     using (MatchDBContext db = new MatchDBContext())
     {
         return(db.Events.ToList());
     }
 }
Beispiel #8
0
 void timer_Elapsed(object s, EventArgs args)
 {
     //db.Database.Delete();
     using (MatchDBContext db = new MatchDBContext()) {
         XmlToDatabase newFilter = new XmlToDatabase();
         newFilter.DataImport();
         newFilter.DeleteOldItems();
         db.SaveChanges();
     }
 }
Beispiel #9
0
        public ActionResult Reject(String name, String email, String jobTitle, String dateTime)
        {
            MatchDBContext dbMatch        = new MatchDBContext();
            CultureInfo    provider       = CultureInfo.InvariantCulture;
            DateTime       jobPublishdate = DateTime.ParseExact(dateTime, "MM/dd/yyyy HHH:mm:ss", provider);
            Match          applicant      = dbMatch.Matches.Find(User.Identity.Name, jobTitle, jobPublishdate.ToString(), email);

            applicant.rejectedByEmployer   = true;
            dbMatch.Entry(applicant).State = EntityState.Modified;
            dbMatch.SaveChanges();
            return(RedirectToAction("Index", "Job"));
        }
Beispiel #10
0
        void sqlDep_OnChange(object s, SqlNotificationEventArgs e)
        {
            if (e.Type == SqlNotificationType.Change)
            {
                var notifHub = GlobalHost.ConnectionManager.GetHubContext <Hubs.NotificationEventHub>();

                using (MatchDBContext db = new MatchDBContext())
                {
                    notifHub.Clients.All.setValuesEvents(db.Events);
                }
            }
            RegisterNotificationEvent();
        }
Beispiel #11
0
        public async Task Test_Update_Match()
        {
            using (var context = new MatchDBContext(options))
            {
                IMatchRepository _matchRepository = new MatchRepository(context);
                var matchService = new MatchService(_matchRepository);

                if (!context.Matches.Any())
                {
                    await context.Matches.AddRangeAsync(Get_mockDefaultListMaches());

                    await context.SaveChangesAsync();
                }

                //Entity can not be null
                Assert.IsFalse(await matchService.UpdateMatch(new MatchEntity()));

                //can not have score less than 0
                Assert.IsFalse(await matchService.UpdateMatch(new MatchEntity {
                    Id = 1, TeamHomeName = "Uruguay", TeamHomeScore = -1, TeamAwayName = "Italy", TeamAwayScore = 0, Created = DateTime.Now
                }));
                Assert.IsFalse(await matchService.UpdateMatch(new MatchEntity {
                    Id = 1, TeamHomeName = "Uruguay", TeamHomeScore = 0, TeamAwayName = "Italy", TeamAwayScore = -1, Created = DateTime.Now
                }));


                //both teams must exist at the same order with same teams
                Assert.IsFalse(await matchService.UpdateMatch(new MatchEntity {
                    Id = 1, TeamHomeName = "Argentina", TeamHomeScore = 0, TeamAwayName = "Italy", TeamAwayScore = 0, Created = DateTime.Now
                }));
                Assert.IsFalse(await matchService.UpdateMatch(new MatchEntity {
                    Id = 1, TeamHomeName = "Argentina", TeamHomeScore = 0, TeamAwayName = "Uruguay", TeamAwayScore = 0, Created = DateTime.Now
                }));
                Assert.IsFalse(await matchService.UpdateMatch(new MatchEntity {
                    Id = 1, TeamHomeName = "Uruguay", TeamHomeScore = 0, TeamAwayName = "Argentina", TeamAwayScore = 0, Created = DateTime.Now
                }));
                Assert.IsFalse(await matchService.UpdateMatch(new MatchEntity {
                    Id = 1, TeamHomeName = "Australia", TeamHomeScore = 0, TeamAwayName = "Argentina", TeamAwayScore = 0, Created = DateTime.Now
                }));


                Assert.IsTrue(await matchService.UpdateMatch(new MatchEntity {
                    Id = 1, TeamHomeName = "Uruguay", TeamHomeScore = 5, TeamAwayName = "Italy", TeamAwayScore = 0, Created = DateTime.Now
                }));
            }
        }
Beispiel #12
0
        public async Task Test_Start_Match()
        {
            using (var context = new MatchDBContext(options))
            {
                IMatchRepository _matchRepository = new MatchRepository(context);
                var matchService = new MatchService(_matchRepository);

                if (!context.Matches.Any())
                {
                    await context.Matches.AddRangeAsync(Get_mockDefaultListMaches());

                    await context.SaveChangesAsync();
                }

                //Entity can not be null
                Assert.IsFalse(await matchService.StartMatch(new MatchEntity()));

                //can not start with score more than 0
                Assert.IsFalse(await matchService.StartMatch(new MatchEntity {
                    Id = 1, TeamHomeName = "Uruguay", TeamHomeScore = 1, TeamAwayName = "Italy", TeamAwayScore = 0, Created = DateTime.Now
                }));
                Assert.IsFalse(await matchService.StartMatch(new MatchEntity {
                    Id = 1, TeamHomeName = "Uruguay", TeamHomeScore = 0, TeamAwayName = "Italy", TeamAwayScore = 1, Created = DateTime.Now
                }));

                ////both teams must not exist
                Assert.IsFalse(await matchService.StartMatch(new MatchEntity {
                    Id = 1, TeamHomeName = "Argentina", TeamHomeScore = 0, TeamAwayName = "Italy", TeamAwayScore = 0, Created = DateTime.Now
                }));
                Assert.IsFalse(await matchService.StartMatch(new MatchEntity {
                    Id = 1, TeamHomeName = "Argentina", TeamHomeScore = 0, TeamAwayName = "Uruguay", TeamAwayScore = 0, Created = DateTime.Now
                }));
                Assert.IsFalse(await matchService.StartMatch(new MatchEntity {
                    Id = 1, TeamHomeName = "Uruguay", TeamHomeScore = 0, TeamAwayName = "Argentina", TeamAwayScore = 0, Created = DateTime.Now
                }));
                Assert.IsFalse(await matchService.StartMatch(new MatchEntity {
                    Id = 1, TeamHomeName = "Australia", TeamHomeScore = 0, TeamAwayName = "Argentina", TeamAwayScore = 0, Created = DateTime.Now
                }));

                //insert new entity with no errors
                Assert.IsTrue(await matchService.StartMatch(new MatchEntity {
                    Id = 6, TeamHomeName = "EEUU", TeamHomeScore = 0, TeamAwayName = "Portugal", TeamAwayScore = 0, Created = DateTime.Now
                }));
            }
        }
Beispiel #13
0
        public IActionResult JoinPost([FromBody] GameConfig config)
        {
            GameBoard.ConstructBoard(config, out GameBoard board);     //constructs board from config object
            MatchDBContext context = HttpContext.RequestServices.GetService(typeof(MatchDBContext)) as MatchDBContext;
            List <Match>   matches = context.GetAllMatches();          //go to MatchDBContext and code your own getter for some query

            if (matches.Count == 0)
            {
                //need to create new match
                context.AddNewMatch(Match.MakeNewMatch(board, config));
            }
            else
            {
                matches[0].JoinMatch(board);
                context.UpdateMatchRecord(matches[0]);
            }
            return(new ObjectResult(board));            //stub, currently just returns board object as json, board obj
        }
Beispiel #14
0
        public async Task Test_Get_Match()
        {
            using (var context = new MatchDBContext(options))
            {
                //just to have empty database and insert same element options to compare with the result
                context.Database.EnsureDeleted();

                IMatchRepository _matchRepository = new MatchRepository(context);
                var matchService = new MatchService(_matchRepository);

                if (!context.Matches.Any())
                {
                    await context.Matches.AddRangeAsync(Get_mockDefaultListMaches());

                    await context.SaveChangesAsync();
                }

                //can not return same default order
                Assert.AreNotEqual(Get_mockDefaultListMaches(), await matchService.GetOrderedScore());

                //can be same list order from mock data
                CollectionAssert.AreEqual(Get_mockOrderedListMaches(), await matchService.GetOrderedScore(), new MatchComparer());
            }
        }
Beispiel #15
0
        public ActionResult eligibleApplicants(String id, String Hour, String Minute, String Seconds, String Millisecond, String Ticks, String jobTitle, String tags, String education, String time)
        {
            //http://stackoverflow.com/questions/1757214/linq-entity-string-field-contains-any-of-an-array-of-strings
            ApplicantDBContext dbApplicant = new ApplicantDBContext();
            //String test = { "mustard", "pickles", "relish" };
            //var possible = dbApplicant.Applicants.Any(x => (x.Education.Contains(education)));
            //var possible = from p in dbApplicant.Applicants
            //               where search.Any(x=>p.Education.Contains);
            var requriedEducationarray     = education.Split('|');
            var requriedIntrestedJobsarray = tags.Split('|');
            //var test = dbApplicant.Applicants.Any(str => str.Education.Split('|').Intersect(education.Split('|')).Any());
            var result = from p in dbApplicant.Applicants
                         where requriedEducationarray.Any(val => p.Education.Contains(val))
                         select p;
            var result2 = from p in result
                          where requriedIntrestedJobsarray.Any(val => p.IntrestedJobs.Contains(val))
                          select p;


            MatchDBContext dbMatch        = new MatchDBContext();
            CultureInfo    provider       = CultureInfo.InvariantCulture;
            DateTime       jobPublishdate = DateTime.ParseExact(time, "MM/dd/yyyy HHH:mm:ss", provider);
            String         theDate        = jobPublishdate.ToString();

            //old matches
            //var thisEmployersMatches = dbMatch.Matches.Where(x => (x.EmployerEmailAddress.Equals(User.Identity.Name))).Select(x => x.ApplicantEmailAddress).ToArray();
            //Filtering based on employer id and the job title
            var thisEmployersMatches = dbMatch.Matches.Where(x => ((x.EmployerEmailAddress.Equals(User.Identity.Name)) &&
                                                                   (x.JobTitle.Equals(jobTitle))));

            //Filtering based on job pubish date as it a unique identifier
            var filteredBasedOnJobPublishedDate = thisEmployersMatches.Where(x => x.PublishDate.Equals(theDate));

            ///////////For filtering  rejected Applicants to display ONLY FOR returning to view//////////////

            // Only showing matches which were not rejected by this employer
            var filteredBasedOnRejectedByEmployer = filteredBasedOnJobPublishedDate.Where(x => x.rejectedByEmployer == false);
            // Only showing matches which were not rejected by an applicant
            var filteredBasedOnRejectedByApplicantList = filteredBasedOnRejectedByEmployer.Where(x => x.rejectedByEmployer == false);
            //list of Applicant names that were not rejected
            //var listOfNonRejectedApplicantNames = filteredBasedOnRejectedByApplicantList.Select(x => x.ApplicantEmailAddress).ToList();


            //////////////////////////////////////////////
            //Gives a list of applicants to ignore for adding to the db
            var listOfExisingApplicantNames = filteredBasedOnJobPublishedDate.Select(x => x.ApplicantEmailAddress).ToArray();
            //var all = amp.Select(x =>x.ApplicantEmailAddress);
            //var result2filtered = ;

            var result4 = from p in result2
                          where !listOfExisingApplicantNames.Any(val => p.email.Contains(val))
                          select p;

            if (result4.Count() == 0)
            {
                //var test1 = thisEmployersMatches.ToList();
                //var test2 = listOfNonRejectedApplicantNames;
                return(View(filteredBasedOnRejectedByApplicantList.ToList()));
            }



            foreach (var item in result4)
            {
                //int count = requriedEducationarray.Where(val => item.Education.Contains(val)).Count();
                var educationListOfCurrentApplicant = item.Education.Split('|');
                var countSimilarityEducation        = requriedEducationarray.Intersect(educationListOfCurrentApplicant).Count();

                var intrestedJobsListOfCurrentApplicant = item.IntrestedJobs.Split('|');
                var countSimilarityIntrestedJobs        = requriedIntrestedJobsarray.Intersect(intrestedJobsListOfCurrentApplicant).Count();
                //calculating score////
                var startScore = 5;
                var a1         = requriedEducationarray.Length - countSimilarityEducation;
                var a2         = requriedIntrestedJobsarray.Length - countSimilarityIntrestedJobs;
                var overAll    = startScore - (a1 + a2);

                Match match = new Match
                {
                    EmployerEmailAddress  = User.Identity.Name,
                    JobTitle              = jobTitle,
                    ApplicantEmailAddress = item.email,
                    PublishDate           = jobPublishdate.ToString(),
                    ApplicantName         = item.firstName + " " + item.lastName,
                    overAllScore          = overAll,
                    acceptedByApplicant   = false,
                    acceptedByEmployer    = false,
                    rejectedByApplicant   = false,
                    rejectedByEmployer    = false
                };

                dbMatch.Matches.Add(match);
            }
            dbMatch.SaveChanges();

            //return View(dbMatch.Matches.ToList());
            return(View(filteredBasedOnRejectedByApplicantList.ToList()));
        }
Beispiel #16
0
 public PlayersRepo()
 {
     db = new MatchDBContext();
 }
Beispiel #17
0
        public void DataImport()
        {
            //try
            //{
            //    DeleteOldItems();//Delete old Matches
            //}
            //catch
            //{
            //    throw new Exception();
            //}
            XmlDocument doc = new XmlDocument();

            try
            {
                doc.Load(@"http://vitalbet.net/sportxml"); // NWebFile
                //doc.Load(@"C:\Users\momo\Desktop\Livebet5.01.2017-9.00h-working\Livebet5.01.2017-19.00h-working-FinallToSend\Livebet\Livebet\XMLFile2.xml");//Locall File
            }
            catch
            {
            }

            //----------------------fromXml----------------------------------------
            XmlNodeList elementListSports = doc.GetElementsByTagName("Sport");
            XmlNodeList elementListEvent  = doc.GetElementsByTagName("Event");
            XmlNodeList elementListMatch  = doc.GetElementsByTagName("Match");
            XmlNodeList elementListBet    = doc.GetElementsByTagName("Bet");
            XmlNodeList elementListOdd    = doc.GetElementsByTagName("Odd");


            try
            {
                foreach (XmlNode item in elementListSports)
                {
                    using (MatchDBContext db = new MatchDBContext())
                    {
                        db.Sports.AddOrUpdate(s => s.Id,
                                              new Sport()
                        {
                            Id   = CheckIntegers(item.Attributes["ID"]),
                            Name = CheckStrings(item.Attributes["Name"])
                        });

                        db.SaveChanges();
                    }
                }
            }
            catch
            {}
            try
            {
                foreach (XmlNode item2 in elementListEvent)
                {
                    using (MatchDBContext db = new MatchDBContext())
                    {
                        db.Events.AddOrUpdate(e => e.Id,
                                              new Event()
                        {
                            Id   = CheckIntegers(item2.Attributes["ID"]),
                            Name = CheckStrings(item2.Attributes["Name"]),

                            IsLive     = CheckBooleans(item2.Attributes["IsLive"]),
                            Sport_ID   = CheckIntegers(item2.ParentNode.Attributes["ID"]),
                            CategoryID = CheckIntegers(item2.Attributes["CategoryID"])
                        });
                        db.SaveChanges();
                    }
                }
            }
            catch
            { }
            try
            {
                foreach (XmlNode itemMatch in elementListMatch)
                {
                    DateTime startDate = Convert.ToDateTime(itemMatch.Attributes["StartDate"].Value);
                    if (startDate.AddHours(3) > DateTime.Now.ToUniversalTime() && startDate.AddHours(-3) < DateTime.Now.ToUniversalTime().AddHours(24))
                    {
                        using (MatchDBContext db = new MatchDBContext())
                        {
                            int id = Convert.ToInt32(itemMatch.Attributes["ID"].Value);

                            db.Matches.AddOrUpdate(m => m.Id,
                                                   new Match()
                            {
                                Id        = id,
                                Name      = CheckStrings(itemMatch.Attributes["Name"]),
                                StartDate = startDate,
                                Type      = CheckStrings(itemMatch.Attributes["MatchType"]),

                                Event_ID = CheckIntegers(itemMatch.ParentNode.Attributes["ID"])
                            });
                            db.SaveChanges();
                        }


                        foreach (XmlNode itemBets in itemMatch.ChildNodes)
                        {
                            using (MatchDBContext db = new MatchDBContext())
                            {
                                db.Bets.AddOrUpdate(b => b.Id,
                                                    new Bet()
                                {
                                    Id       = CheckIntegers(itemBets.Attributes["ID"]),
                                    Name     = CheckStrings(itemBets.Attributes["Name"]),
                                    IsLive   = CheckBooleans(itemBets.Attributes["IsLive"]),
                                    Match_ID = CheckIntegers(itemBets.ParentNode.Attributes["ID"])
                                });

                                db.SaveChanges();
                            }



                            foreach (XmlNode itemOdds in itemBets.ChildNodes)
                            {
                                using (MatchDBContext db = new MatchDBContext())
                                {
                                    try
                                    {
                                        db.Odds.AddOrUpdate(o => o.Id,
                                                            new Odd()
                                        {
                                            Id              = CheckIntegers(itemOdds.Attributes["ID"]),
                                            Name            = CheckStrings(itemOdds.Attributes["Name"]),
                                            Value           = CheckStrings(itemOdds.Attributes["Value"]),
                                            Bet_ID          = CheckIntegers(itemOdds.ParentNode.Attributes["ID"]),
                                            SpecialBetValue = CheckStrings(itemOdds.Attributes["SpecialBetValue"])
                                        });

                                        db.SaveChanges();
                                    }
                                    catch
                                    { }
                                }
                            }
                        }
                    }
                }
            }
            catch
            { }
        }
Beispiel #18
0
 public MatchRepo()
 {
     db = new MatchDBContext();
 }
Beispiel #19
0
 public MatchController()
 {
     db = new MatchDBContext();
 }
Beispiel #20
0
 public TeamsRepo()
 {
     db = new MatchDBContext();
 }
Beispiel #21
0
 public MatchRepository(MatchDBContext dBContext)
 {
     _dbContext = dBContext;
 }
Beispiel #22
0
        public ActionResult ApplicantMatches()
        {
            MatchDBContext dbMatch   = new MatchDBContext();
            JobDBContext   dbJob     = new JobDBContext();
            Applicant      applicant = db.Applicants.Find(User.Identity.Name);
            var            requriedEducationarray     = applicant.Education.Split('|');
            var            requriedIntrestedJobsarray = applicant.IntrestedJobs.Split('|');
            //var test = dbApplicant.Applicants.Any(str => str.Education.Split('|').Intersect(education.Split('|')).Any());
            var result = from p in dbJob.Jobs
                         where requriedEducationarray.Any(val => p.Education.Contains(val))
                         select p;
            //type=job
            var allPossibleJobs = from p in result
                                  where requriedIntrestedJobsarray.Any(val => p.Tags.Contains(val))
                                  select p;
            //Job matches that the user already has
            var thisApplicantMatches = dbMatch.Matches.Where(x => (x.ApplicantEmailAddress.Equals(User.Identity.Name)));
            //Convert the jobs into matches
            List <Match> matches = new List <Match>();

            foreach (var job in allPossibleJobs)
            {
                var educationListOfCurrentApplicant = job.Education.Split('|');
                var countSimilarityEducation        = requriedEducationarray.Intersect(educationListOfCurrentApplicant).Count();

                var   intrestedJobsListOfCurrentApplicant = job.Tags.Split('|');
                var   countSimilarityIntrestedJobs        = requriedIntrestedJobsarray.Intersect(intrestedJobsListOfCurrentApplicant).Count();
                var   startScore = 5;
                var   a1         = requriedEducationarray.Length - countSimilarityEducation;
                var   a2         = requriedIntrestedJobsarray.Length - countSimilarityIntrestedJobs;
                var   overAll    = startScore - (a1 + a2);
                Match match      = new Match
                {
                    EmployerEmailAddress  = job.EmployerEmailAddress,
                    JobTitle              = job.JobTitle,
                    PublishDate           = job.PublishDate,
                    ApplicantEmailAddress = User.Identity.Name,
                    ApplicantName         = applicant.firstName + " " + applicant.lastName,
                    overAllScore          = overAll,
                    acceptedByApplicant   = false,
                    acceptedByEmployer    = false,
                    rejectedByApplicant   = false,
                    rejectedByEmployer    = false
                };
                matches.Add(match);
            }
            //Now start removing existing matches
            //var newMatches = matches.Where(y => (thisApplicantMatches.Any(z => z.JobTitle != y.JobTitle))&&
            //thisApplicantMatches.Any(z => z.PublishDate != y.PublishDate));
            //var matchesAll = thisApplicantMatches.Select(a => new { a.JobTitle, a.EmployerEmailAddress, a.PublishDate });
            //var toAddMatches = matches.Where(a => !matchesAll.Contains(new { a.JobTitle, a.EmployerEmailAddress, a.PublishDate })).ToList();
            var toAddMatches = matches.Where(sc => !thisApplicantMatches.Any(dc => dc.JobTitle == sc.JobTitle &&
                                                                             dc.PublishDate == sc.PublishDate && dc.EmployerEmailAddress == sc.EmployerEmailAddress));

            foreach (var item in toAddMatches)
            {
                dbMatch.Matches.Add(item);
            }

            dbMatch.SaveChanges();
            var thisApplicantMatches2 = dbMatch.Matches.Where(x => (x.ApplicantEmailAddress.Equals(User.Identity.Name)));
            // Only showing matches which were not rejected by this employer
            var filteredBasedOnRejectedByEmployer = thisApplicantMatches2.Where(x => x.rejectedByEmployer == false);
            // Only showing matches which were not rejected by an applicant
            var filteredBasedOnRejectedByApplicantList = filteredBasedOnRejectedByEmployer.Where(x => x.rejectedByEmployer == false);

            //return View(thisApplicantMatches);
            return(View(filteredBasedOnRejectedByApplicantList.ToList()));
        }