public AutoPunishment(string term, AutoPunishmentType type, TimeSpan duration) { Term = term; Type = type; Duration = duration; PunishedUsers = new List <PunishedUser>(); }
public AutoPunishment Get(string term, AutoPunishmentType type) { var entity = _entities.FirstOrDefault(e => e.Term == term && e.Type == type); return(entity == null ? null : new AutoPunishment(entity)); }
private IReadOnlyList <ISendable <ITransmittable> > _addPunishment(string punishedPhrase, TimeSpan duration, AutoPunishmentType type, string name) { var autoPunishment = _unitOfWork.Query(u => u.AutoPunishments.Get(punishedPhrase, type)); if (autoPunishment == null) { _unitOfWork.Command(u => u.AutoPunishments.Add(new AutoPunishment(punishedPhrase, type, duration))); return(new SendablePublicMessage($"{punishedPhrase} added to {name} list for {duration.ToPretty(_logger)}").Wrap().ToList()); } autoPunishment.Duration = duration; _unitOfWork.Command(u => u.AutoPunishments.Update(autoPunishment)); return(new SendablePublicMessage($"{punishedPhrase} is already in the {name} list. Its duration has been updated to {duration.ToPretty(_logger)}").Wrap().ToList()); }
private IReadOnlyList <ISendable <ITransmittable> > _deletePunishment(string punishedPhrase, AutoPunishmentType type, string name) { var autoPunishment = _unitOfWork.Query(u => u.AutoPunishments.Get(punishedPhrase, type)); if (autoPunishment == null) { return(new SendablePublicMessage($"{punishedPhrase} is not in the {name} list").Wrap().ToList()); } _unitOfWork.Command(u => u.AutoPunishments.Delete(autoPunishment)); return(new SendablePublicMessage($"{punishedPhrase} deleted from the {name} list").Wrap().ToList()); }