コード例 #1
0
 private Band(int id, string name, Bandit boss, IEnumerable <Bandit> members)
 {
     Id      = id;
     Name    = name;
     Boss    = BandMember.From(boss, this);
     Members = members.Select(m => BandMember.From(m, this)).ToList();
     Rounds  = new List <Round>();
 }
コード例 #2
0
ファイル: RoundMember.cs プロジェクト: shohnn/SheriffAPI
        private RoundMember(BandMember member, Round round)
        {
            Member  = member;
            Round   = round;
            Scoring = Score.Zero;

            round.TrackMember(this);
        }
コード例 #3
0
ファイル: Round.cs プロジェクト: shohnn/SheriffAPI
 private Round(int id, string name, string place, DateTime dateTime, BandMember sheriff, IEnumerable <BandMember> members)
 {
     Id       = id;
     Name     = name;
     Place    = place;
     DateTime = dateTime;
     Sheriff  = RoundMember.From(sheriff, this);
     Members  = members.Select(m => RoundMember.From(m, this)).ToList();
 }
コード例 #4
0
ファイル: Extensions.cs プロジェクト: shohnn/SheriffAPI
 public static BandMember ToDtoBand(this Models.BandMember band)
 {
     return(new BandMember
     {
         Id = band.Band.Id,
         Band = band.Band.Name,
         Scoring = band.Scoring.ToDto()
     });
 }
コード例 #5
0
ファイル: Extensions.cs プロジェクト: shohnn/SheriffAPI
 public static MemberBand ToDtoMember(this Models.BandMember member)
 {
     return(new MemberBand
     {
         Id = member.Bandit.Id,
         Member = member.Bandit.Name,
         Scoring = member.Scoring.ToDto()
     });
 }
コード例 #6
0
        public bool CanCreateRound(BandMember sheriff)
        {
            if (sheriff == null)
            {
                throw new ArgumentNullException(nameof(sheriff));
            }

            if (!Members.Contains(sheriff))
            {
                return(false);
            }

            return(Members.All(m => m.Rounds.Count >= sheriff.Rounds.Count));
        }
コード例 #7
0
ファイル: RoundMember.cs プロジェクト: shohnn/SheriffAPI
        public static RoundMember From(BandMember member, Round round)
        {
            if (member == null)
            {
                throw new ArgumentNullException(nameof(member));
            }

            if (round == null)
            {
                throw new ArgumentNullException(nameof(round));
            }

            return(new RoundMember(member, round));
        }
コード例 #8
0
ファイル: Round.cs プロジェクト: shohnn/SheriffAPI
        public static Round Create(int id, string name, string place, DateTime dateTime, BandMember sheriff, IEnumerable <BandMember> members)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException(Strings.NullOrEmpty.Format(nameof(name)), nameof(name));
            }

            if (string.IsNullOrEmpty(place))
            {
                throw new ArgumentException(Strings.NullOrEmpty.Format(nameof(place)), nameof(place));
            }

            if (sheriff == null)
            {
                throw new ArgumentNullException(nameof(sheriff));
            }

            if (members == null)
            {
                throw new ArgumentNullException(nameof(members));
            }

            if (members.Any(m => m == null))
            {
                throw new ArgumentException(Strings.ContainsNull.Format(nameof(members)), nameof(members));
            }

            if (members.Any(m => m.Band != sheriff.Band))
            {
                throw new ArgumentException(Strings.ShouldBeInSameBand, nameof(members));
            }

            return(new Round(id, name, place, dateTime, sheriff, members));
        }