Пример #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
        private RoundMember(BandMember member, Round round)
        {
            Member  = member;
            Round   = round;
            Scoring = Score.Zero;

            round.TrackMember(this);
        }
Пример #3
0
 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
 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
 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
        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
        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));
        }