public void Update(AutoPunishment autoPunishment) { var entity = _single(autoPunishment.Id); autoPunishment.CopyTo(entity); _entities.Update(entity); }
public void Add(AutoPunishment autoPunishment) { var entity = new AutoPunishmentEntity(); autoPunishment.CopyTo(entity); _entities.Add(entity); }
public void Delete(AutoPunishment autoPunishment) { var entity = new AutoPunishmentEntity(); autoPunishment.CopyTo(entity); _entities.Remove(entity); }
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)); }