Exemple #1
0
        public List <MatchType> GetMatches(GameType game, ParticipantTypes soloOrTeam, MatchCategories matchCategory)
        {
            List <MatchType> filtered = new List <MatchType>();

            filtered = grda.MatchList;

            for (int i = 0; i < grda.MatchList.Count; i++)
            {
                if (grda.MatchList[i].GameID.Equals(game) && grda.MatchList[i].Category.Equals(matchCategory))
                {
                    //solo or team?
                    if ((grda.MatchList[i] is SoloMatch) && (soloOrTeam == ParticipantTypes.Solo))
                    {
                        filtered.Add(grda.MatchList[i]);
                    }
                    else if ((grda.MatchList[i] is TeamMatch) && (soloOrTeam == ParticipantTypes.Team))
                    {
                        filtered.Add(grda.MatchList[i]);
                    }
                    else if (soloOrTeam == ParticipantTypes.All)
                    {
                        filtered.Add(grda.MatchList[i]);
                    }
                }
            }
            return(filtered);
        }
        public async Task <IActionResult> Edit(int id, [Bind("IdParticipantType,ParticipantType")] ParticipantTypes participantTypes)
        {
            if (id != participantTypes.IdParticipantType)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(participantTypes);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ParticipantTypesExists(participantTypes.IdParticipantType))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(participantTypes));
        }
 /// <summary>
 /// Creates a game
 /// </summary>
 /// <param name="name"> name of the game </param>
 /// <param name="partType"> participant type </param>
 public GameType(string name, ParticipantTypes partType)
 {
     if (String.IsNullOrEmpty(name))
     {
         throw new System.ArgumentException("Name cannot be 'null' or empty!");
     }
     Name            = name;
     ParticipantType = partType;
 }
        public async Task <IActionResult> Create([Bind("IdParticipantType,ParticipantType")] ParticipantTypes participantTypes)
        {
            //if (!User.IsInRole("admin")) RedirectToAction("Denied", "Account");
            if (ModelState.IsValid)
            {
                _context.Add(participantTypes);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(participantTypes));
        }
 public List<PlayerGameRankingType> GetGameRankingsAll(GameType game, ParticipantTypes soloOrTeam)
 {
     List<PlayerGameRankingType> rankings = new List<PlayerGameRankingType>();
     foreach (PlayerGameRankingType r in backend.RankingList)
     {
         if ((r.Game == game) && (!rankings.Contains(r)))
         {
             rankings.Add(r);
         }
     }
     return rankings;
 }
Exemple #6
0
        public void Start()
        {
            Player = new Player();
            Dealer = new Dealer();

            Hit(Player);
            Hit(Player);

            Hit(Dealer);
            Hit(Dealer);

            GameFinished = false;
            Turn         = ParticipantTypes.Player;
        }
        public IAuthenticationRequest CreateAuthenticationRequest(ParticipantTypes requestType, string deviceId, Guid cityId)
        {
            switch (requestType)
            {
            case ParticipantTypes.Driver:
                return(new DriverAuthenticationRequestSLO(cityId));

                break;

            case ParticipantTypes.Pedestrian:
                return(new PedestrianAuthenticationRequestSLO(cityId));

                break;

            default:
                throw new NotImplementedException();
                break;
            }
        }
Exemple #8
0
        public AuthenticationRequestModel CreateAuthenticationRequest(ParticipantTypes requestType)
        {
            switch (requestType)
            {
            case ParticipantTypes.Driver:
                return(new DriverAuthenticationRequestModel());

                break;

            case ParticipantTypes.Pedestrian:
                return(new PedestrianAuthenticationRequestModel());

                break;

            default:
                throw new NotImplementedException();
                break;
            }
        }
Exemple #9
0
        /// <summary>
        /// Returns all filtered matches
        /// </summary>
        /// <param name="game"> game </param>
        /// <param name="soloOrTeam"> participant type </param>
        /// <param name="matchCategory"> match category </param>
        /// <returns> filtered matches </returns>
        public List <MatchType> GetMatches(GameType game, ParticipantTypes soloOrTeam, MatchCategories matchCategory)
        {
            List <MatchType> matches = new List <MatchType>();

            foreach (MatchType m in backend.MatchList)
            {
                if (m.GameID == game && m.Category == matchCategory)
                {
                    if ((soloOrTeam == ParticipantTypes.Solo) && (m is TeamMatch))
                    {
                        continue;
                    }
                    if ((soloOrTeam == ParticipantTypes.Team) && (m is SoloMatch))
                    {
                        continue;
                    }
                    if (!matches.Contains(m))
                    {
                        matches.Add(m);
                    }
                }
            }
            return(matches);
        }
        public async Task <IActionResult> Import(IFormFile fileExcel)
        {
            if (ModelState.IsValid)
            {
                if (fileExcel != null)
                {
                    using (var stream = new FileStream(fileExcel.FileName, FileMode.Create))
                    {
                        await fileExcel.CopyToAsync(stream);

                        using (XLWorkbook workBook = new XLWorkbook(stream, XLEventTracking.Disabled))
                        {
                            foreach (IXLWorksheet worksheet in workBook.Worksheets)
                            {
                                ParticipantTypes newtype;
                                var t = (from type in _context.ParticipantTypes where type.ParticipantType.Contains(worksheet.Name) select type).ToList();
                                if (t.Count > 0)
                                {
                                    newtype = t[0];
                                }

                                else
                                {
                                    newtype = new ParticipantTypes();
                                    newtype.ParticipantType = worksheet.Name;
                                    _context.ParticipantTypes.Add(newtype);
                                }
                                //перегляд усіх рядків
                                foreach (IXLRow row in worksheet.RowsUsed().Skip(1))
                                {
                                    try
                                    {
                                        //участник
                                        Participants participant = new Participants();
                                        var          p           = (from part in _context.Participants where part.ParticipantName == row.Cell(1).Value.ToString() select part).ToList();
                                        if (p.Count > 0)
                                        {
                                            participant = p[0];
                                        }
                                        else
                                        {
                                            participant.ParticipantName = row.Cell(1).Value.ToString();
                                            participant.ParticipantDate = Convert.ToDateTime(row.Cell(2).Value.ToString());
                                            participant.Biography       = row.Cell(3).Value.ToString();

                                            //участник -> город
                                            Cities newcity;
                                            var    c = (from city in _context.Cities where city.CityName.Contains(row.Cell(4).Value.ToString()) select city).ToList();
                                            if (c.Count > 0)
                                            {
                                                newcity = c[0];
                                            }
                                            else
                                            {
                                                newcity             = new Cities();
                                                newcity.CityName    = row.Cell(4).Value.ToString();
                                                newcity.Description = "Imported from file.";
                                                _context.Cities.Add(newcity);
                                            }

                                            participant.IdRepresentedCityNavigation = newcity;
                                            participant.IdParticipantTypeNavigation = newtype;
                                            _context.Participants.Add(participant);
                                        }

                                        //участие
                                        Participations participation = new Participations();
                                        var            pt            = (from parts in _context.Participations where parts.IdParticipantNavigation.ParticipantName == row.Cell(1).Value.ToString() select parts).ToList();
                                        if (pt.Count > 0)
                                        {
                                            participation = pt[0];
                                        }
                                        else
                                        {
                                            //песня
                                            Songs song = new Songs();
                                            var   s    = (from songs in _context.Songs where song.SongName == row.Cell(5).Value.ToString() select songs).ToList();
                                            if (s.Count > 0)
                                            {
                                                song = s[0];
                                            }
                                            else
                                            {
                                                song.SongName = row.Cell(5).Value.ToString();
                                                string   myString = row.Cell(6).Value.ToString();
                                                double   d        = double.Parse(myString);
                                                DateTime dt       = DateTime.FromOADate(d);
                                                song.Duration = new TimeSpan(dt.Hour, dt.Minute, dt.Second);
                                                _context.Songs.Add(song);
                                            }

                                            //участие -> год
                                            Years newyear;
                                            var   y = (from year in _context.Years where year.YearOfContest == int.Parse(row.Cell(7).Value.ToString()) select year).ToList();
                                            if (y.Count > 0)
                                            {
                                                newyear = y[0];
                                            }
                                            else
                                            {
                                                newyear = new Years();
                                                newyear.YearOfContest = Convert.ToInt32(row.Cell(7).Value);
                                                newyear.Slogan        = "Slogan";
                                                newyear.Stage         = "Stage";
                                                foreach (var city in _context.Cities)
                                                {
                                                    if (city.CityName == "POLIGON")
                                                    {
                                                        newyear.IdHostCityNavigation = city;
                                                        break;
                                                    }
                                                }
                                                _context.Years.Add(newyear);
                                            }

                                            //участие -> номинация
                                            Nominations newnomination;
                                            var         n = (from nomination in _context.Nominations where nomination.NominationName.Contains(row.Cell(8).Value.ToString()) select nomination).ToList();
                                            if (n.Count > 0)
                                            {
                                                newnomination = n[0];
                                            }
                                            else
                                            {
                                                newnomination = new Nominations();
                                                newnomination.NominationName = row.Cell(8).Value.ToString();
                                                _context.Nominations.Add(newnomination);
                                            }


                                            participation.IdParticipantNavigation   = participant;
                                            participation.IdSongNavigation          = song;
                                            participation.IdYearOfContestNavigation = newyear;
                                            participation.IdNominationNavigation    = newnomination;
                                            participation.Place = Convert.ToInt32(row.Cell(9).Value);

                                            _context.Participations.Add(participation);
                                        }
                                    }
                                    catch
                                    {
                                        RedirectToAction("ErrorOpen", "Home");
                                    }
                                }
                            }
                        }
                    }
                }

                await _context.SaveChangesAsync();
            }
            return(RedirectToAction(nameof(Index)));
        }
 /// <summary>
 /// Returns all filtered matches
 /// </summary>
 /// <param name="game"> game </param>
 /// <param name="soloOrTeam"> participant type </param>
 /// <param name="matchCategory"> match category </param>
 /// <returns> filtered matches </returns>
 public List<MatchType> GetMatches(GameType game, ParticipantTypes soloOrTeam, MatchCategories matchCategory)
 {
     List<MatchType> matches = new List<MatchType>();
     foreach (MatchType m in backend.MatchList)
     {
         if (m.GameID == game && m.Category == matchCategory)
         {
             if ((soloOrTeam == ParticipantTypes.Solo) && (m is TeamMatch))
             {
                 continue;
             }
             if ((soloOrTeam == ParticipantTypes.Team) && (m is SoloMatch))
             {
                 continue;
             }
             if (!matches.Contains(m))
             {
                 matches.Add(m);
             }
         }
     }
     return matches;
 }
 public List <PlayerGameRankingType> GetGameRankingsAll(GameType game, ParticipantTypes soloOrTeam)
 {
     throw new NotImplementedException();
 }
Exemple #13
0
 public void StickPlayer()
 {
     Player.Stick = true;
     Turn         = ParticipantTypes.Dealer;
 }
 public List<MatchType> GetMatches(GameType game, ParticipantTypes soloOrTeam, MatchCategories matchCategory)
 {
     throw new NotImplementedException();
 }
 public List<PlayerGameRankingType> GetGameRankingsAll(GameType game, ParticipantTypes soloOrTeam)
 {
     throw new NotImplementedException();
 }
Exemple #16
0
 public Participant(string firstName, string lastName, ParticipantTypes participantType)
 {
     FirstName       = firstName;
     LastName        = lastName;
     ParticipantType = participantType;
 }
 public List <MatchType> GetMatches(GameType game, ParticipantTypes soloOrTeam, MatchCategories matchCategory)
 {
     throw new NotImplementedException();
 }