public async void SendNewNoteEmailToSuppliers(Entity.Models.Request request, Entity.Models.Note note) { if (request.SupplierId.HasValue == false) { return; } var vendorUrl = _configuration.GetValue <string>("VendorWebsite:BaseUrl"); var noteDetailPath = string.Format(_configuration.GetValue <string>("VendorWebsite:NoteDetail"), note.Id); var subject = $"Vandivier Product Request Note"; var users = _dbReadService.GetAllRecordsAsync <Entity.Models.User>(x => x.SupplierId == request.SupplierId).Result; foreach (var user in users) { var body = $"A new note has been added for a product request that requires your attention. <br /><br />" + $"View the note <a href='{vendorUrl}{noteDetailPath}'>here</a> <br /><br />" + $"Thanks, <br /> Vandivier Management"; if (user.EmailAddress != null) { Helper.Send(_configuration, subject, body, new List <string>() { user.EmailAddress }); } } }
public void SendNewNoteEmailToOriginatingUser(Entity.Models.Request request, Entity.Models.Note note, int?supplierId = 0) { if (supplierId != null && supplierId > 0) { var vendorUrl = _configuration.GetValue <string>("VendorWebsite:BaseUrl"); var noteDetailPath = string.Format(_configuration.GetValue <string>("VendorWebsite:NoteDetail"), note.Id); var subject = $"Vandivier Product Request Note"; var emailAddress = new GraphClient(_configuration, false).GetUserEmail(request.UserId); var body = $"A new note has been added for a product request that requires your attention. <br /><br />" + $"View the note <a href='{vendorUrl}{noteDetailPath}'>here</a> <br /><br />" + $"Thanks, <br /> Vandivier Management"; if (emailAddress != null) { Helper.Send(_configuration, subject, body, new List <string>() { emailAddress }); } } else { var adminUrl = _configuration.GetValue <string>("AdminWebsite:BaseUrl"); var noteDetailPath = string.Format(_configuration.GetValue <string>("AdminWebsite:NoteDetail"), note.Id); var subject = $"Vandivier Product Request Note"; var emailAddress = new GraphClient(_configuration, false).GetUserEmail(request.UserId); var body = $"A new note has been added for a product request that requires your attention. <br /><br />" + $"View the note <a href='{adminUrl}{noteDetailPath}'>here</a> <br /><br />" + $"Thanks, <br /> Vandivier Management"; if (emailAddress != null) { Helper.Send(_configuration, subject, body, new List <string>() { emailAddress }); } } }
public void SendNewNoteEmailToStoreManagers(Entity.Models.Request request, Entity.Models.Note note) { var adminUrl = _configuration.GetValue <string>("AdminWebsite:BaseUrl"); var noteDetailPath = string.Format(_configuration.GetValue <string>("AdminWebsite:NoteDetail"), note.Id); var subject = $"Vandivier Product Request Note"; var emailAddresses = new GraphClient(_configuration, false).GetGroupUsersEmail(_configuration.GetValue <string>("SecurityGroups:StoreManager")); foreach (var emailAddress in emailAddresses) { var body = $"A new note has been added for a product request that requires your attention. <br /><br />" + $"View the note <a href='{adminUrl}{noteDetailPath}'>here</a> <br /><br />" + $"Thanks, <br /> Vandivier Management"; if (emailAddress != null) { Helper.Send(_configuration, subject, body, new List <string>() { emailAddress }); } } }