private void SendCancelledReservationMail(Movie movie) { List <Reservation> reservations = (db.Repo <Reservation>() as IReservationsRepo).GetReservationsForMovie(movie); foreach (var reservation in reservations) { mail.SendMail(reservation.CinemaUser.Email, "Anulowanie rezerwacji", string.Format( "Twoje rezerwacje na film {0} zostały anulowane", movie.Title)); } }
public bool SendMailToCustomer(string toAddress, string name) { //Actual logic goes here //define message and mail address _mailSender.SendMail("*****@*****.**", "Some Message"); return(true); }
public Task Process(CancelRepairCommand request, Unit response) { var repair = _dbContext.Repairs.Where(r => r.Id.ToString() == request.Id) .Include(r => r.Vehicle) .ThenInclude(v => v.Client) .FirstOrDefault(); string receiverAddress = repair.Vehicle.Client.ContactDetails.Email; string receiverName = $"{repair.Vehicle.Client.FirstName} {repair.Vehicle.Client.LastName}"; _mailSender.SendMail(receiverAddress, receiverName, "Twoja naprawa została anulowana.<br>"); return(Task.FromResult(0)); }
/// <summary> /// Is called from DriveReport Patch. /// Sends email to the user associated with the report identified by key, with notification about rejected report. /// </summary> /// <param name="key"></param> /// <param name="delta"></param> public void SendMailForRejectedReport(int key, Delta <DriveReport> delta) { var report = _driveReportRepository.AsQueryable().FirstOrDefault(r => r.Id == key); var recipient = ""; if (report != null && !String.IsNullOrEmpty(report.Person.Mail)) { recipient = report.Person.Mail; } else { _logger.LogForAdmin("Forsøg på at sende mail om afvist indberetning til " + report.Person.FullName + ", men der findes ingen emailadresse. " + report.Person.FullName + " har derfor ikke modtaget en mailadvisering"); throw new Exception("Forsøg på at sende mail til person uden emailaddresse"); } var comment = new object(); if (delta.TryGetPropertyValue("Comment", out comment)) { _mailSender.SendMail(recipient, "Afvist indberetning", "Din indberetning er blevet afvist med kommentaren: \n \n" + comment + "\n \n Du har mulighed for at redigere den afviste indberetning i OS2indberetning under Mine indberetninger / Afviste, hvorefter den vil lægge sig under Afventer godkendelse - fanen igen."); } }
public void Send(string username, string email, string id, string activationcode) { byte[] tokenGeneratedBytes = Encoding.UTF8.GetBytes(activationcode); activationcode = WebEncoders.Base64UrlEncode(tokenGeneratedBytes); string host = conf["EmailSettings:LinkHost"]; var verifyUrl = $"{host}/Account/Verify?id={id}&token={activationcode}"; string subject = "Verify your account"; string body = $"<br/><br/>We are excited to tell you, <strong>{username}</strong>, that your account is" + " successfully created. Please click on the below link to verify your account" + " <br/><br/><a href='" + verifyUrl + "'>" + verifyUrl + "</a> "; sender.SendMail(email, body, subject); }
/// <summary> /// Sends an email to all leaders with pending reports to be approved. /// </summary> public void SendMails() { var startOfDay = ToUnixTime(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 00, 00, 00)); var endOfDay = ToUnixTime(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59)); var notifications = mailScheduleRepo.AsQueryable().Where(r => r.DateTimestamp >= startOfDay && r.DateTimestamp <= endOfDay && !r.Notified); if (!notifications.Any()) { logger.LogInformation("No notifications found"); } else { logger.LogInformation("Email notification(s) found"); foreach (var notification in notifications.ToList()) { if (notification.Repeat) { var newDateTime = ToUnixTime(FromUnixTime(notification.DateTimestamp).AddMonths(1)); mailScheduleRepo.Insert(new MailNotificationSchedule() { DateTimestamp = newDateTime, Notified = false, Repeat = true }); } notification.Notified = true; var reports = GetLeadersWithPendingReportsMails(); var distinctReportTypesPerEmail = reports.GroupBy(report => new { report.ReportType, report.ResponsibleLeader.Mail }); foreach (var report in distinctReportTypesPerEmail) { switch (report.Key.ReportType) { case ReportType.Drive: // _mailSender.SendMail(report.ResponsibleLeader.Mail, ConfigurationManager.AppSettings[""], driveBody); break; case ReportType.Vacation: mailSender.SendMail(report.Key.Mail, config["Mail:VacationMail:Subject"], config["Mail:VacationMail:Body"]); break; default: logger.LogError("Kunne ikke finde typen af rapport: " + report.Key.ReportType); break; } } } mailScheduleRepo.Save(); } }
public void Send() { var configvalue = ConfigurationManager.AppSettings["PROTECTED_DailyErrorLogMail"]; if (configvalue == null) { return; } configvalue = Regex.Replace(configvalue, @"\s+", ""); var receivers = configvalue.Split(','); var webLines = _logReader.Read("C:\\logs\\os2eindberetning\\web.log"); var dmzLines = _logReader.Read("C:\\logs\\os2eindberetning\\dmz.log"); var mailLines = _logReader.Read("C:\\logs\\os2eindberetning\\mail.log"); var webMessage = String.Join(Environment.NewLine, _logParser.Messages(webLines, DateTime.Now.AddDays(-1))); var dmzMessage = String.Join(Environment.NewLine, _logParser.Messages(dmzLines, DateTime.Now.AddDays(-1))); var mailMessage = String.Join(Environment.NewLine, _logParser.Messages(mailLines, DateTime.Now.AddDays(-1))); var newLine = System.Environment.NewLine; var result = ""; // Only add each header if there are log messages in that category. if (webMessage.Any()) { result += "Web:" + newLine + newLine + webMessage + newLine + newLine; } if (dmzMessage.Any()) { result += "DMZ: " + newLine + newLine + dmzMessage + newLine + newLine; } if (mailMessage.Any()) { result += "Mail: " + newLine + newLine + mailMessage; } if (result == "") { result = "Ingen fejl registreret"; } foreach (var receiver in receivers) { _mailSender.SendMail(receiver, "Log", result); } }
public Task Process(CreatePricingCommand request, Unit response) { var repair = _dbContext.Repairs.Where(r => r.Id == request.RepairId) .Include(r => r.Vehicle) .ThenInclude(v => v.Client) .Include(r => r.Pricing) .FirstOrDefault(); string receiverAddress = repair.Vehicle.Client.ContactDetails.Email; string receiverName = $"{repair.Vehicle.Client.FirstName} {repair.Vehicle.Client.LastName}"; string message = $"Twój numer naprawy to {repair.Pricing.ClientRepairNumber} .<br>"; _mailSender.SendMail(receiverAddress, receiverName, message); return(Task.FromResult(0)); }
public void SendInvitation(Guid UUID, Ballot ballot, string pollQuestion) { if (String.IsNullOrWhiteSpace(ballot.Email)) { return; } string hostUri = WebConfigurationManager.AppSettings["HostURI"]; if (String.IsNullOrWhiteSpace(hostUri)) { return; } string link = hostUri + "/Poll/#/" + UUID + "/Vote/" + ballot.TokenGuid; string htmlMessage = (string)_invitationTemplate; htmlMessage = htmlMessage.Replace("__VOTEURI__", link); htmlMessage = htmlMessage.Replace("__HOSTURI__", hostUri); htmlMessage = htmlMessage.Replace("__POLLQUESTION__", pollQuestion); _mailSender.SendMail(ballot.Email, "Have your say", htmlMessage); }
public void SendChangePasswordMail(User user) { var token = Cryptography.GenerateTokenById(user.Id.Value, ConfigurationReader.EncryptKey); var url = new UrlHelper(HttpContext.Current.Request.RequestContext); var changePasswordUrl = url.AbsoluteAction( "ChangePassword", "Account", new { token, area = string.Empty }); var changePasswordLink = $@"<a href=""{changePasswordUrl}""><strong>{changePasswordUrl}</strong></a><br/>"; var path = Path.Combine( HttpContext.Current.Server.MapPath("~/App_Data"), @"Templates\RequestNewPasswordTemplate.html"); var messageBody = FileOperator.ReadFile(path); messageBody = messageBody.Replace("$$userFullName", user.UserName); messageBody = messageBody.Replace("$$requestNewPasswordLink", changePasswordLink); var email = new Email { Content = Encoding.UTF8.GetBytes(messageBody), RecepientId = user.Id.Value, SendUserId = ConfigurationReader.AutomationUserId, SentMailMessageType = EnumHelper.GetMessageTypeIdByEnum(SentMailMessageType.ForgottenPasswordMail) }; using (var transaction = contextManager.NewTransaction()) { userService.UpdatePasswordToken(user.Id.Value, token); email.Id = emailService.Insert(email); transaction.Commit(); } mailSender.SendMail(email.Id.Value, user.Email, Resource.ResetPassword); }
public bool SendForgottenPasswordEmail(string recipientEmailAddress, ISystemUserRepository repository) { ISystemUser matchingUser = repository.GetByEmailAddress(recipientEmailAddress); bool sendEmail = (matchingUser != null); if (sendEmail) { string clearTextPassword = _encryptionEngine.Decrypt(matchingUser.Password); MailMessage mail = _mailFactory.CreateEmail(recipientEmailAddress, clearTextPassword); _mailSender.SendMail(mail); } return(sendEmail); }
/// <summary> /// Provides logic to registrate new user, sends confirmation mail if everything's done ok /// </summary> /// <param name="registrationModel"></param> /// <param name="uri"></param> public void Registrate(RegistartionViewModel registrationModel, Uri uri) { Guid key = _authProvider.RegistrateUser(registrationModel.User.NickName, registrationModel.Password); StringBuilder mailBody = new StringBuilder(); mailBody.Append("<html><head></head><body><div>Click link to confirm your account <a href=\"http://"); mailBody.Append(uri.Authority); mailBody.Append("/Confirm/"); mailBody.Append(registrationModel.User.NickName); mailBody.Append("/"); mailBody.Append(key); mailBody.Append("\">here</a></body></html>"); _mailSender.SendMail("Your new account", mailBody.ToString(), registrationModel.User.Email); }
static void Main() { var responsibles = ""; for (int i = 0; i < 50; i++) { responsibles += "<tr>" + "<td><span>Abra kadabra<span></span></span></td>" + "<td><span>800</span></td>" + "<td><span>348</span></td>" + "<td><span>713</span></td>" + "<td><span>3</span></td>" + "<td><span>648</span></td>" + "<td><span>0</span></td>" + "<td><span>2</span></td>" + "<td><span>205</span></td>" + "</tr>"; } var message = new MailMessage("123", "<style>.red{background:red;} " + "table{border-spacing: 0px; border-top: 1px solid black;border-right: 1px solid black;font-size:14px;margin:5px;padding:5px;}" + "table th, table td{border-left: 1px solid black;border-bottom: 1px solid black;text-align: center;}</style>" + "<table><thead>" + "<tr>" + "<th rowspan=\"2\" colspan=\"1\"><span>Ответственный</span></th>" + "<th rowspan=\"2\" colspan=\"1\"><span>План месяца</span></th>" + "<th rowspan=\"2\" colspan=\"1\"><span>План</span></th>" + "<th colspan=\"5\" rowspan=\"1\"><span>Факт</span></th>" + "<th rowspan=\"2\" colspan=\"1\"><span>% прогноз выполнения плана</span></th>" + "</tr>" + "<tr>" + "<th rowspan=\"1\" colspan=\"1\"><span>Итого баллов</span></th>" + "<th rowspan=\"1\" colspan=\"1\"><span>Встреча</span></th>" + "<th rowspan=\"1\" colspan=\"1\"><span>Звонок</span></th>" + "<th rowspan=\"1\" colspan=\"1\"><span>Семинар</span></th>" + "<th rowspan=\"1\" colspan=\"1\"><span>Дистанционная встреча</span></th>" + "</tr>" + "</thead>" + "<tbody>" + responsibles + "</tbody></table>"); sender.SendMail(message, new[] { "email" }); }
public IActionResult New(Attorney attorney) { if (!_usersRepo.VerifyUsername(attorney.User.Username)) { ModelState.AddModelError("uqUsername", "El usuario ingresado ya existe"); } if (!_attorneysRepo.VerifyEmail(attorney.Email)) { ModelState.AddModelError("uqEmail", "El correo ingresado ya existe"); } if (!_attorneysRepo.VerifyNotaryCode(attorney.NotaryCode)) { ModelState.AddModelError("uqNotaryCode", "El código de notario ingresado ya existe"); } //if(attorney.User.Username.Contains(" ")) //{ // ModelState.AddModelError("whiteSpacesUsername", "El nombre de usuario contiene espacios en blanco, favor no incluir espacios en blanco"); //} if (!ModelState.IsValid) { NewAttorneyViewModel viewModel = new NewAttorneyViewModel { Departments = _departmentsRepo.Departments.ToList() }; viewModel.Attorney = attorney; return(View(viewModel)); } else { //string guidGenerated = _guidManager.GenerateGuid(); //string passwordDefault = guidGenerated.Substring(guidGenerated.Length - 12, 12); string passwordOriginal = attorney.User.Password; string passwordHashed = _cryptoManager.HashString(attorney.User.Password); attorney.User.Password = passwordHashed; _attorneysRepo.Save(attorney); //Envío de password sin hash al usuario string emailBody = $"Se le ha creado un acceso a la aplicación Lexincorp Nicaragua Web, su usuario es {attorney.User.Username} " + $"y su clave de acceso es {passwordOriginal}. \n**Este es un mensaje autogenerado por el sistema, favor no responder**"; _mailSender.SendMail(attorney.Email, "Usuario web creado para aplicación Lexincorp Nicaragua Web", emailBody); TempData["added"] = true; return(RedirectToAction("New")); } }
private static void SendMail(IMailSender mailSender, MailSettings credentialSettings) { MailInfo mailInfo = new MailInfo() { From = "Muhammet Kaya", Body = "This is test body.", Subject = "This Test Mail", IsBodyHtml = false, IsDeliveryReceiptRequest = true, IsReadReceiptRequest = true, ToRecipients = new string[] { "*****@*****.**" } }; //Client is initializing mailSender.InitializeClient(credentialSettings); //Mail is sending mailSender.SendMail(mailInfo); }
public Result Send(MessageTemplateType type, SystemMailEntity systemMail, object additionalData) { var result = GetMailResult(type, systemMail, additionalData, out MailEntity mail); if (result.Success == false) { return(result); } using (_mailSender) { _mailSender.SendMail(mail); } result = new Result(true, $"Message sended to user({systemMail.To})."); return(result); }
/// <summary> /// Sends an email to all leaders with pending reports to be approved. /// </summary> public void SendMails(DateTime payRoleDateTime) { var mailAddresses = GetLeadersWithPendingReportsMails(); var mailBody = ConfigurationManager.AppSettings["PROTECTED_MAIL_BODY"]; if (string.IsNullOrEmpty(mailBody)) { _logger.Debug($"{this.GetType().Name}, SendMails(): Mail body is null or empty, check value in CustomSettings.config"); } mailBody = mailBody.Replace("####", payRoleDateTime.ToString("dd-MM-yyyy")); var mailSubject = ConfigurationManager.AppSettings["PROTECTED_MAIL_SUBJECT"]; if (string.IsNullOrEmpty(mailSubject)) { _logger.Debug($"{this.GetType().Name}, SendMails(): Mail subject is null or empty, check value in CustomSettings.config"); } foreach (var mailAddress in mailAddresses) { _mailSender.SendMail(mailAddress, ConfigurationManager.AppSettings["PROTECTED_MAIL_SUBJECT"], mailBody); } }
/// <summary> /// Migrate employees from kommune database to OS2 database. /// </summary> public void MigrateEmployees() { _logger.Debug($"{this.GetType().Name}, MigrateEmployees() started"); foreach (var person in _personRepo.AsQueryable()) { person.IsActive = false; } _logger.Debug($"{this.GetType().Name}, MigrateEmployees(), All persons IsActive = false. Amount of persons in personrepo= {_personRepo.AsQueryable().Count()}"); _personRepo.Save(); var empls = _dataProvider.GetEmployeesAsQueryable(); var i = 0; var distinctEmpls = empls.DistinctBy(x => x.CPR).ToList(); _logger.Debug($"{this.GetType().Name}, MigrateEmployees() Amount of employees in distinctEmpls: {distinctEmpls.Count()}"); foreach (var employee in distinctEmpls) { i++; if (i % 10 == 0) { Console.WriteLine("Migrating person " + i + " of " + distinctEmpls.Count() + "."); } var personToInsert = _personRepo.AsQueryable().FirstOrDefault(x => x.CprNumber.Equals(employee.CPR)); if (personToInsert == null) { personToInsert = _personRepo.Insert(new Person()); personToInsert.IsAdmin = false; personToInsert.RecieveMail = true; } personToInsert.CprNumber = employee.CPR ?? "ikke opgivet"; personToInsert.FirstName = employee.Fornavn ?? "ikke opgivet"; personToInsert.LastName = employee.Efternavn ?? "ikke opgivet"; personToInsert.Initials = employee.ADBrugerNavn ?? " "; personToInsert.FullName = personToInsert.FirstName + " " + personToInsert.LastName + " [" + personToInsert.Initials + "]"; personToInsert.Mail = employee.Email ?? ""; personToInsert.IsActive = true; } _personRepo.Save(); _logger.Debug($"{this.GetType().Name}, MigrateEmployees(), Users are active again"); /**g * We need the person id before we can attach personal addresses * so we loop through the distinct employees once again and * look up the created persons */ i = 0; foreach (var employee in distinctEmpls) { if (i % 50 == 0) { Console.WriteLine("Adding home address to person " + i + " out of " + distinctEmpls.Count()); } i++; var personToInsert = _personRepo.AsQueryable().First(x => x.CprNumber == employee.CPR); UpdateHomeAddress(employee, personToInsert.Id); if (i % 500 == 0) { _personalAddressRepo.Save(); } } _logger.Debug($"{this.GetType().Name}, MigrateEmployees(), Home adresses updated."); _personalAddressRepo.Save(); //Sets all employments to end now in the case there was //one day where the updater did not run and the employee //has been removed from the latest MDM view we are working on //The end date will be adjusted in the next loop foreach (var employment in _emplRepo.AsQueryable()) { employment.EndDateTimestamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; } _logger.Debug($"{this.GetType().Name}, MigrateEmployees(), All employments end date set to now."); _emplRepo.Save(); i = 0; foreach (var employee in empls) { i++; if (i % 10 == 0) { Console.WriteLine("Adding employment to person " + i + " of " + empls.Count()); } var personToInsert = _personRepo.AsQueryable().First(x => x.CprNumber == employee.CPR); CreateEmployment(employee, personToInsert.Id); if (i % 500 == 0) { _emplRepo.Save(); } } _logger.Debug($"{this.GetType().Name}, MigrateEmployees(), Employments added to persons."); _personalAddressRepo.Save(); _emplRepo.Save(); // Makes all employees wihtout employments inactive. var peopleWithoutEmployment = _personRepo.AsQueryable().Where(x => !x.Employments.Any()); foreach (var person in peopleWithoutEmployment) { person.IsActive = false; } _personRepo.Save(); Console.WriteLine("Before Dirty Adresses"); var dirtyAddressCount = _cachedRepo.AsQueryable().Count(x => x.IsDirty); if (dirtyAddressCount > 0) { _logger.Debug($"{this.GetType().Name}, MigrateEmployees(), There are {dirtyAddressCount} dirty address(es)."); foreach (var admin in _personRepo.AsQueryable().Where(x => x.IsAdmin && x.IsActive)) { _mailSender.SendMail(admin.Mail, "Der er adresser der mangler at blive vasket", "Der mangler at blive vasket " + dirtyAddressCount + "adresser"); } } Console.WriteLine("Done migrating employees"); }
public bool SendMailToCustomer() { return(_mailSender.SendMail("*****@*****.**", "Some Message"));; }
public async Task SendAsync(IdentityMessage message) { await mailSender.SendMail(message.Destination, message.Subject, message.Body); }
public bool SendMailToCustomer() { _mailSender.SendMail("*****@*****.**", "Hello User.. Welcome!"); return(true); }
public void Send() { var configvalue = ConfigurationManager.AppSettings["PROTECTED_DailyErrorLogMail"]; configvalue = Regex.Replace(configvalue, @"\s+", ""); var receivers = configvalue.Split(','); var webLines = new List <string>(); var dbupdaterLines = new List <string>(); var dmzLines = new List <string>(); var mailLines = new List <string>(); try { webLines = _logReader.Read("C:\\logs\\os2eindberetning\\admin\\web.log"); dbupdaterLines = _logReader.Read("C:\\logs\\os2eindberetning\\admin\\dbupdater.log"); dmzLines = _logReader.Read("C:\\logs\\os2eindberetning\\admin\\dmz.log"); mailLines = _logReader.Read("C:\\logs\\os2eindberetning\\admin\\mail.log"); } catch (Exception ex) { _logger.Error($"{GetType().Name}, Send(), Error when trying to read from an admin log file", ex); throw ex; } var webMessage = String.Join(Environment.NewLine, _logParser.Messages(webLines, DateTime.Now.AddDays(-1))); var dbupdaterMessage = String.Join(Environment.NewLine, _logParser.Messages(dbupdaterLines, DateTime.Now.AddDays(-1))); var dmzMessage = String.Join(Environment.NewLine, _logParser.Messages(dmzLines, DateTime.Now.AddDays(-1))); var mailMessage = String.Join(Environment.NewLine, _logParser.Messages(mailLines, DateTime.Now.AddDays(-1))); var newLine = System.Environment.NewLine; var result = ""; // Only add each header if there are log messages in that category. if (webMessage.Any()) { result += "Web:" + newLine + newLine + webMessage + newLine + newLine; } if (dbupdaterMessage.Any()) { result += "DBUpdater:" + newLine + newLine + webMessage + newLine + newLine; } if (dmzMessage.Any()) { result += "DMZ: " + newLine + newLine + dmzMessage + newLine + newLine; } if (mailMessage.Any()) { result += "Mail: " + newLine + newLine + mailMessage; } if (result == "") { result = "Ingen fejl registreret"; } foreach (var receiver in receivers) { _mailSender.SendMail(receiver, "Log", result); } }
public bool SendMailToCustomer() { _mailSender.SendMail("*****@*****.**", "Hallo User"); return(true); }
public void AnswerClosureNotification(int notificationAnswerId, int userId, bool isAffirmative, out bool wasClosed) { if (CheckPendingAnswer(notificationAnswerId, userId)) { var usersToNotify = context.Users .Where(u => u.Active && u.Username != "webAdmin" && u.Id != userId) .Select(u => new { UserId = u.Id, Email = u.Attorney.Email }).ToList(); string petitionerUser = context.Users .Where(u => u.Id == userId) .Select(u => u.Username).First(); var notification = context.ClosureNotifications .Where(cn => cn.NotificationAnswers.Any(na => na.Id == notificationAnswerId)) .First(); var packageToClose = context.Packages.Where(p => p.Id == notification.PackageId) .Select(p => new { p.Name, ClientName = p.Client.Name }) .First(); //Check if there is no users besides the petitioner to have to answer to the notification //Ignoring the default webAdmin user //In the case that is rejected the notification itself if (!isAffirmative) { notification.Active = false; notification.WasClosed = false; var notificationAnswer = new NotificationAnswer { Id = notificationAnswerId, IsAnswered = true, WasAffirmative = false }; context.NotificationAnswers.Attach(notificationAnswer); context.Entry(notificationAnswer).Property(na => na.IsAnswered).IsModified = true; context.Entry(notificationAnswer).Property(na => na.WasAffirmative).IsModified = true; context.SaveChanges(); //Notify that it was cancelled if (usersToNotify.Any()) { //Notify that the closure was cancelled var emailsToNotify = usersToNotify.Select(u => u.Email).ToList(); string subject = $"Cierre de paquete {packageToClose.Name} denegado"; string body = $"El usuario {petitionerUser} ha denegado una solicitud para cerrar el paquete '{packageToClose.Name}' del cliente {packageToClose.ClientName}. " + $"\n**Este es un mensaje autogenerado por el sistema, favor no responder**"; mailer.SendMail(emailsToNotify, subject, body); } wasClosed = false; } else { //In the case is accepted var notificationAnswer = new NotificationAnswer { Id = notificationAnswerId, IsAnswered = true, WasAffirmative = true }; context.NotificationAnswers.Attach(notificationAnswer); context.Entry(notificationAnswer).Property(na => na.IsAnswered).IsModified = true; context.Entry(notificationAnswer).Property(na => na.WasAffirmative).IsModified = true; context.SaveChanges(); //Check if there is no more pending answers if (!context.NotificationAnswers.Any(na => na.ClosureNotificationId == notification.Id && !na.IsAnswered)) { //Meaning that the package can be closed notification.Active = false; notification.WasClosed = true; var targetPackage = new Package { Id = notification.PackageId, IsFinished = true }; context.Packages.Attach(targetPackage); context.Entry(targetPackage).Property(p => p.IsFinished).IsModified = true; context.SaveChanges(); //Notify that the package was successfully closed var emailsToNotify = usersToNotify.Select(u => u.Email).ToList(); string subject = $"Cierre de paquete {packageToClose.Name} completado"; string body = $"Se ha marcado como finalizado el paquete '{packageToClose.Name}' del cliente {packageToClose.ClientName} " + $"dado que ha sido permitido por todos los usuarios activos. " + $"\n**Este es un mensaje autogenerado por el sistema, favor no responder**"; mailer.SendMail(emailsToNotify, subject, body); wasClosed = true; } else { wasClosed = false; } } } else { wasClosed = false; } }
public string SendMail(string toAddress, string subject) { var mailResult = _mailSender.SendMail(toAddress, subject); return(mailResult); }
public IResult SendMail(string movieName, string to) { return(_mailsender.SendMail("*****@*****.**", to, "Film Tavsiyesi", "Bu filmi izlemelisin:" + movieName)); }
public bool SendMailToCustomer() { _mailSender.SendMail("*****@*****.**", "Some Message"); return(true); }