コード例 #1
0
        public void Update(AutoPunishment autoPunishment)
        {
            var entity = _single(autoPunishment.Id);

            autoPunishment.CopyTo(entity);
            _entities.Update(entity);
        }
コード例 #2
0
        public void Add(AutoPunishment autoPunishment)
        {
            var entity = new AutoPunishmentEntity();

            autoPunishment.CopyTo(entity);
            _entities.Add(entity);
        }
コード例 #3
0
        public void Delete(AutoPunishment autoPunishment)
        {
            var entity = new AutoPunishmentEntity();

            autoPunishment.CopyTo(entity);
            _entities.Remove(entity);
        }
コード例 #4
0
        private ISendable <Punishment> CalculatePunishment(Civilian sender, AutoPunishment autoPunishment, Func <Civilian, TimeSpan, string, ISendable <Punishment> > punishmentCtor)
        {
            var punishedUser = autoPunishment.PunishedUsers.SingleOrDefault(u => u.Nick == sender.Nick);
            var duration     = autoPunishment.Duration;
            var reason       = $"{duration.ToPretty(_logger)} for prohibited phrase";

            if (punishedUser != null)
            {
                duration = autoPunishment.Duration.Multiply(Math.Pow(2, punishedUser.Count));
                reason   = punishedUser.Count == 1
          ? $"{duration.ToPretty(_logger)} for prohibited phrase; your time has doubled. Future sanctions will not be explicitly justified."
          : "";
            }
            _unitOfWork.Command(r => r.PunishedUsers.Increment(sender.Nick, autoPunishment.Term));
            return(punishmentCtor(sender, duration, reason));
        }