private (List <Recipient> recipients, IEnumerable <WishCategory> wishes) PrepareData() { _table = _documentsFactory.OpenDataTable(); var recipients = _table.GetRecipients().ToList(); var wishes = _table.GetWishes(); _table.Close(); _table = null; return(recipients, wishes); }
public void Generate() { try { var(recipients, wishes) = PrepareData(); _distributor = _distributorFactory.CreateDistributor(wishes); if (_distributor.IsEnoughWishes(recipients.Count)) { GenerateLettersText(recipients); FinishGeneration(); } else { throw new NotEnoughWishesException(); } } catch (Exception) { _template?.CloseDoc(); _table?.Close(); throw; } }