public void PrepareMail() { List <StoreInformation> storesInformation = GetStoreAndManagerDetails(); foreach (var storeInfo in storesInformation) { List <Batch> batches = BatchLogic.GetBatchesForAllProductsForStore(storeInfo.Store.Id); List <MailAddress> receipientsMailAddress = new List <MailAddress>(); foreach (var record in storeInfo.StoreManagers) { string receipientName = record.FirstName + " " + record.LastName; if (!string.IsNullOrWhiteSpace(record.Email)) { receipientsMailAddress.Add(new MailAddress(record.Email, receipientName)); } } string content = ComposeMail(batches, storeInfo.Store); SendEmail(storeInfo.Store, receipientsMailAddress, "Inventory Information", content, ""); } }
public EmailLogic(IRepository <Store> _storesRepo, BatchLogic _batchL) { StoresRepo = _storesRepo; BatchLogic = _batchL; db = new ApplicationDbContext(); }