private void ProcessTemplate(MailTemplateModel model) { _isEdit = (model != null); Template = (_isEdit) ? model : GetTemplate(); Template.PropertyChanged += TemplateOnPropertyChanged; }
public async void LoadData() { IsBusy = true; _crmDataUnit.MailTemplatesRepository.Refresh(); var templates = await _crmDataUnit.MailTemplatesRepository.GetAllAsync(); MainEmailTemplate = new MailTemplateModel(templates.Where(x => x.MailTemplateCategory.Name == "CRM" && x.MailTemplateType.Name == "MainEmailTemplate").FirstOrDefault()); MailTemplates = new ObservableCollection <MailTemplateModel>(templates.Where(x => x.MailTemplateCategory.Name == "CRM" && x.IsEnabled && x.MailTemplateType.Name != "MainEmailTemplate").OrderBy(x => x.Name).Select(x => new MailTemplateModel(x))); _crmDataUnit.EmailHeadersRepository.Refresh(); var headers = await _crmDataUnit.EmailHeadersRepository.GetAllAsync(); _allEmailHeaders = new List <EmailHeader>(headers); EmailHeaders = new ObservableCollection <EmailHeader>(_allEmailHeaders.Where(x => x.IsEnabled)); var types = await _crmDataUnit.CorresponcenceTypesRepository.GetAllAsync(); _corresponcenceTypes = new List <CorresponcenceType>(types); var appPath = (string)ApplicationSettings.Read("DocumentsPath"); var documets = await _crmDataUnit.DocumentsRepository.GetAllAsync(x => x.IsEnabled && x.IsCommon); Documents = new ObservableCollection <Document>(documets.Where(x => File.Exists(string.Concat(appPath, x.Path)))); OnLoadContacts(); IsBusy = false; }
public static string MailTemplate(string TemplateFileName, MailTemplateModel mt) { string FilePath = string.Empty; FilePath = System.Web.Hosting.HostingEnvironment.MapPath("~\\MailTemplate\\" + TemplateFileName); var mailTemplate = string.Empty; mailTemplate = ReadFile(FilePath).ToString(); mailTemplate = mailTemplate.Replace("$$SiteURL$$", SiteConfigration.webURL); mailTemplate = mailTemplate.Replace("$$SiteLogo$$", SiteConfigration.webURL + SiteConfigration.LogoURL); mailTemplate = mailTemplate.Replace("$$SiteName$$", SiteConfigration.Name); mailTemplate = mailTemplate.Replace("$$Copyrights$$", SiteConfigration.Copyrights); mailTemplate = mailTemplate.Replace("$$SiteEmailAddress$$", SiteConfigration.ContactEmail); mailTemplate = mailTemplate.Replace("$$CustomerName$$", mt.CustomerName); mailTemplate = mailTemplate.Replace("$$CustomerEmail$$", mt.CustomerEmail); mailTemplate = mailTemplate.Replace("$$CustomerContactNo$$", mt.CustomerContactNo); mailTemplate = mailTemplate.Replace("$$CustomerAddress$$", mt.CustomerAddress); mailTemplate = mailTemplate.Replace("$$Message$$", mt.Message); mailTemplate = mailTemplate.Replace("$$RatingstarImage$$", System.Web.Hosting.HostingEnvironment.MapPath("~\\Images\\star\\" + mt.Ratingstar + ".png")); mailTemplate = mailTemplate.Replace("$$ReferralName$$", mt.ReferralName); mailTemplate = mailTemplate.Replace("$$ReferralEmail$$", mt.ReferralEmail); mailTemplate = mailTemplate.Replace("$$ReferralContactNo$$", mt.ReferralContactNo); mailTemplate = mailTemplate.Replace("$$ReferralToName$$", mt.ReferralToName); mailTemplate = mailTemplate.Replace("$$ReferralToEmail$$", mt.ReferralToEmail); mailTemplate = mailTemplate.Replace("$$ReferralToContactNo$$", mt.ReferralToContactNo); mailTemplate = mailTemplate.Replace("$$Budget$$", mt.Budget); return(mailTemplate); }
/// <summary> /// Sends the email. /// </summary> /// <param name="umbracoContext">The umbraco context.</param> /// <param name="emailTemplateName">Name of the email template.</param> /// <param name="to">To.</param> /// <param name="attachment">The attachment.</param> /// <param name="replacementTokens">The replacement tokens.</param> /// <returns></returns> /// <inheritdoc /> public MailResponse SendEmail( UmbracoContext umbracoContext, string emailTemplateName, string to, Attachment attachment, Dictionary <string, string> replacementTokens) { IPublishedContent content = settingsService.GetMailTemplate(emailTemplateName); if (content == null) { throw new ApplicationException("Mail Template " + emailTemplateName + " not defined"); } MailTemplateModel model = new MailTemplateModel(content); string newText = model.Text; if (replacementTokens != null) { foreach (KeyValuePair <string, string> token in replacementTokens) { newText = newText.Replace("$" + token.Key, token.Value); } } model.TokenizedText = newText; if (attachment != null) { model.Attachments.Add(attachment); } return(mailService.SendEmail(to, model)); }
public MailTemplateView(MailTemplateModel model) { InitializeComponent(); DataContext = ViewModel = new MailTemplateViewModel(model); ViewModel.PropertyChanged += ViewModelOnPropertyChanged; Loaded += OnMailTemplateViewLoaded; }
public ActionResult SendEmail(string name, string company, string email, string phone, string budget, string comments) { try { string SMTPUserName = ConfigurationManager.AppSettings["SMTPUserName"]; string FromMailPassword = ConfigurationManager.AppSettings["SMTPPassword"]; string ToMailId = ConfigurationManager.AppSettings["ContactEmail"]; string Host = ConfigurationManager.AppSettings["SMTPHost"]; int Port = Convert.ToInt32(ConfigurationManager.AppSettings["SMTPPort"]); bool EnableSSL = Convert.ToBoolean(ConfigurationManager.AppSettings["SMTPEnableSSL"]); //string Body = "<b>Name</b> : " + name + "<br/>" + "<b>Email</b> : " + email + "<br/>" + "<b>Company Name</b> : " + company + "<br/>" + "<b>Phone Number</b> : " + phone + "<br/>" + "<b>Budget</b> : " + budget + "<br/>" + "<b>Message</b> : " + comments; MailTemplateModel mtCustomer = new MailTemplateModel { CustomerContactNo = phone, CustomerEmail = email, CustomerName = name, Message = comments, Budget = budget }; string AdminMailBody = MailTemplateGenerator.MailTemplate("ContactUsAdmin.html", mtCustomer); string CustomerMailBody = MailTemplateGenerator.MailTemplate("ContactUsCustomer.html", mtCustomer); MailMessage Adminmail = new MailMessage(); SmtpClient AdminSmtpServer = new SmtpClient(Host); AdminSmtpServer.UseDefaultCredentials = false; Adminmail.From = new MailAddress(SMTPUserName); Adminmail.To.Add(ToMailId); Adminmail.Subject = "Business inquiry from " + SiteConfigration.Name; Adminmail.IsBodyHtml = true; Adminmail.Body = AdminMailBody; AdminSmtpServer.Port = Port; AdminSmtpServer.Credentials = new System.Net.NetworkCredential(SMTPUserName, FromMailPassword); AdminSmtpServer.EnableSsl = EnableSSL; AdminSmtpServer.Send(Adminmail); MailMessage Customermail = new MailMessage(); SmtpClient CustomerSmtpServer = new SmtpClient(Host); CustomerSmtpServer.UseDefaultCredentials = false; Customermail.From = new MailAddress(SMTPUserName); Customermail.To.Add(email); Customermail.Subject = "Business inquiry for " + SiteConfigration.Name; Customermail.IsBodyHtml = true; Customermail.Body = CustomerMailBody; CustomerSmtpServer.Port = Port; CustomerSmtpServer.Credentials = new System.Net.NetworkCredential(SMTPUserName, FromMailPassword); CustomerSmtpServer.EnableSsl = EnableSSL; CustomerSmtpServer.Send(Customermail); return(Json("Request submitted successfully. Integrity team will contact you as soon as possible.")); } catch (Exception ex) { return(Json("Email error : " + ex.Message)); } }
private void Save() { try { var mail = new MailTemplateModel(); mail.Id = mailTemplateId; mail.Name = txtName.Text; mail.Description = txtDescription.Text; mail.IsActive = chkIsActive.Checked; mail.Subject = txtSubject.Text; mail.Content = txtContent.Text; var mailTSelect = ((MailSend_Model)cbbMailSend.SelectedItem); if (mail != null) { mail.MailSendId = mailTSelect.Id; } if (this.cbbMailReceives.Properties.Items != null && this.cbbMailReceives.Properties.Items.Count > 0) { foreach (CheckedListBoxItem item in this.cbbMailReceives.Properties.Items) { if (item.CheckState == CheckState.Checked) { mail.MailReceiveIds += (!string.IsNullOrEmpty(mail.MailReceiveIds) ? "|" + item.Value : item.Value); } } } List <int> listFileId = new List <int>(); if (this.listchkFileAttack.Items != null && this.listchkFileAttack.Items.Count > 0) { foreach (CheckedListBoxItem item in this.listchkFileAttack.Items) { if (item.CheckState == CheckState.Checked) { mail.MailFileIds += (!string.IsNullOrEmpty(mail.MailFileIds) ? "|" + item.Value : item.Value); } } } var result = BLLMailTemplate.CreateOrUpdate(mail); MessageBox.Show(result.Messages[0].msg, result.Messages[0].Title); if (result.IsSuccess) { ResetForm(); LoadDataForGridView(); } } catch (Exception ex) { throw ex; } }
public MailTemplateViewModel(MailTemplateModel model) { var dataUnitLocator = ContainerAccessor.Instance.GetContainer().Resolve <IDataUnitLocator>(); _adminDataUnit = dataUnitLocator.ResolveDataUnit <IAdminDataUnit>(); SaveCommand = new RelayCommand(SaveCommandExecuted, SaveCommandCanExecute); CancelCommand = new RelayCommand(CancelCommandExecuted); InsertFieldCommand = new RelayCommand(InsertFieldCommandExecuted); AddTemplateImageCommand = new RelayCommand(AddTemplateImageCommandExecuted); ProcessTemplate(model); }
private void EditTemplateCommandExecuted(MailTemplateModel model) { RaisePropertyChanged("DisableParentWindow"); var view = new MailTemplateView(model); view.ShowDialog(); RaisePropertyChanged("EnableParentWindow"); if (view.DialogResult != null && view.DialogResult == true) { RefreshTemplates(); } }
public IActionResult SaveMailTemplate([FromBody] MailTemplateModel model) { if (string.IsNullOrEmpty(model.Keyname)) { throw new ArgumentNullException(nameof(model.Keyname)); } MailTemplateInfo mailTemplate = _emailManager.GetMailTemplate(model.Keyname); if (mailTemplate != null) { mailTemplate.Subject = model.Subject; mailTemplate.Message = model.Message; _emailManager.UpdateMailTemplate(mailTemplate); return(Ok()); } return(BadRequest("The mail template was not updated")); }
public HttpResponseMessage SendRendezVousVersOutlook(string adressePraticien, string body, string subject, string from, string to, string hdfrom, string hdt) { var statusCode = HttpStatusCode.OK; var mail = new MailTemplateModel { AdressePraticien = adressePraticien, Body = body, Subject = subject, To = to, From = from }; var result = _contactAppServices.SendRendezVousVersOutlook(mail, hdfrom, hdt); if (result != null) { statusCode = (HttpStatusCode)Enum.Parse(typeof(HttpStatusCode), result.StatusDetail.ToString()); } return(Request.CreateResponse(statusCode, result)); }
public async void LoadData() { IsBusy = true; _membershipDataUnit.MailTemplatesRepository.Refresh(); var templates = await _membershipDataUnit.MailTemplatesRepository.GetAllAsync(x => x.MailTemplateCategory.Name == "Membership"); MailTemplates = new ObservableCollection <MailTemplateModel>(templates.Where(x => x.IsEnabled && x.MailTemplateType.Name != "MainEmailTemplate").OrderBy(x => x.Name).Select(x => new MailTemplateModel(x))); MainEmailTemplate = new MailTemplateModel(templates.Where(x => x.MailTemplateType.Name == "MainEmailTemplate").FirstOrDefault()); _membershipDataUnit.EmailHeadersRepository.Refresh(); var headers = await _membershipDataUnit.EmailHeadersRepository.GetAllAsync(); _allEmailHeaders = new List <EmailHeader>(headers); EmailHeaders = new ObservableCollection <EmailHeader>(_allEmailHeaders.Where(x => x.IsEnabled)); var types = await _membershipDataUnit.CorresponcenceTypesRepository.GetAllAsync(x => x.Type == "Member"); _corresponcenceType = types.FirstOrDefault(); IsBusy = false; }
public async void LoadData() { IsBusy = true; var types = await _adminDataUnit.MailTemplateTypesRepository.GetAllAsync(); _mailTemplateTypes = new List <MailTemplateType>(types); var categories = await _adminDataUnit.MailTemplateCategoriesRepository.GetAllAsync(); MailTemplateCategories = new ObservableCollection <MailTemplateCategory>(categories); _adminDataUnit.EmailHeadersRepository.Refresh(); var headers = await _adminDataUnit.EmailHeadersRepository.GetAllAsync(); if (_template != null && _template.EmailHeader != null) { EmailHeaders = new ObservableCollection <EmailHeader>(headers.Where(x => x.IsEnabled || x.ID == _template.EmailHeader.ID)); } else { EmailHeaders = new ObservableCollection <EmailHeader>(headers.Where(x => x.IsEnabled)); } if (_isEdit) { var desiredTemplate = await _adminDataUnit.MailTemplatesRepository.GetUpdatedMailTemplate(_template.MailTemplate.ID); // Check if we have new changes if (desiredTemplate != null && _template.LoadedTime < desiredTemplate.LastUpdatedDate) { Template = new MailTemplateModel(desiredTemplate); } } IsBusy = false; }
/// <inheritdoc /> /// <summary> /// Sends the email. /// </summary> /// <param name="to">To.</param> /// <param name="model">The model.</param> /// <returns></returns> public MailResponse SendEmail( string to, MailTemplateModel model) { string mailTo = model.To; if (string.IsNullOrEmpty(mailTo)) { mailTo = to; } MailResponse response = new MailResponse { Contents = model.TokenizedText, Sent = true, ToEmailAddress = mailTo }; if (model.SurpressSendEmail == false) { MailMessage mailMessage = new MailMessage { From = new MailAddress(model.From), Subject = model.Subject, Body = model.TokenizedText, IsBodyHtml = model.IsHtml }; string[] emailto = mailTo.Split(';'); foreach (string mail in emailto) { if (mail != string.Empty) { mailMessage.To.Add(mail); } } if (string.IsNullOrEmpty(model.BlindCopy) == false) { string[] emailBcc = model.BlindCopy.Split(';'); foreach (string mail in emailBcc) { if (mail != string.Empty) { mailMessage.Bcc.Add(mail); } } } if (model.Attachments != null) { foreach (Attachment attachment in model.Attachments) { mailMessage.Attachments.Add(attachment); } } SmtpClient smtpClient = new SmtpClient(); smtpClient.Send(mailMessage); } return(response); }
public static ResponseBase CreateOrUpdate(MailTemplateModel obj) { var result = new ResponseBase(); var flag = true; MAIL_TEMPLATE mailTemplate = null; MAIL_T_M attachFile = null; try { var db = new PMSEntities(); if (BLLMailTemplate.CheckExists(obj.Id, obj.Name) != null) { result.IsSuccess = false; result.Messages.Add(new Message() { Title = "Lỗi", msg = "Tên mail này đã tồn tại." }); } else { if (obj.Id == 0) { mailTemplate = new MAIL_TEMPLATE(); Parse.CopyObject(obj, ref mailTemplate); //mailTemplate.Name = obj.Name; //mailTemplate.Subject = obj.Subject; //mailTemplate.Content = obj.Content; //mailTemplate.MailSendId = obj.MailSendId; //mailTemplate.MailReceiveIds = obj.MailReceiveIds; //mailTemplate.MailFileIds = obj.MailFileIds; //mailTemplate.Description = obj.Description; //mailTemplate.IsActive = obj.IsActive; //if (obj.AttachFiles != null && obj.AttachFiles.Count > 0) //{ // mailTemplate.MAIL_T_M = new List<MAIL_T_M>(); // foreach (var item in obj.AttachFiles) // { // attachFile = new MAIL_T_M(); // attachFile.MailFileId = item; // attachFile.MAIL_TEMPLATE = mailTemplate; // mailTemplate.MAIL_T_M.Add(attachFile); // } //} db.MAIL_TEMPLATE.Add(mailTemplate); } else { mailTemplate = db.MAIL_TEMPLATE.FirstOrDefault(x => !x.IsDeleted && x.Id == obj.Id); if (mailTemplate != null) { mailTemplate.Name = obj.Name; mailTemplate.Subject = obj.Subject; mailTemplate.Content = obj.Content; mailTemplate.MailSendId = obj.MailSendId; mailTemplate.MailReceiveIds = obj.MailReceiveIds; mailTemplate.MailFileIds = obj.MailFileIds; mailTemplate.Description = obj.Description; mailTemplate.IsActive = obj.IsActive; //if (obj.AttachFileChange) //{ // var oldAtt = db.MAIL_T_M.Where(x => !x.IsDeleted && x.MailTemplateId == mailTemplate.Id); // var ids = new List<int>(); // if (oldAtt != null && oldAtt.Count() > 0) // { // if (obj.AttachFiles != null && obj.AttachFiles.Count > 0) // { // foreach (var item in obj.AttachFiles) // { // var exists = oldAtt.FirstOrDefault(x => x.MailFileId == item); // if (exists != null) // { // ids.Add(exists.Id); // } // else // { // attachFile = new MAIL_T_M(); // attachFile.MailFileId = item; // attachFile.IsActive = true; // attachFile.MailTemplateId = mailTemplate.Id; // db.MAIL_T_M.Add(attachFile); // } // } // } // var deleteobj = oldAtt.Where(x => !ids.Contains(x.Id)); // foreach (var item in deleteobj) // { // item.IsDeleted = true; // } // } // else // { // foreach (var item in obj.AttachFiles) // { // attachFile = new MAIL_T_M(); // attachFile.MailFileId = item; // attachFile.MailTemplateId = mailTemplate.Id; // attachFile.IsActive = true; // db.MAIL_T_M.Add(attachFile); // } // } //} } else { result.IsSuccess = false; result.Messages.Add(new Message() { Title = "Thông Báo", msg = "Không tìm thấy thông tin Mail bạn đang thao tác." }); } } if (flag) { db.SaveChanges(); result.IsSuccess = true; result.Messages.Add(new Message() { Title = "Thông Báo", msg = "Lưu thành công." }); } } } catch (Exception ex) { throw ex; } return(result); }
private bool EditTemplateCommandCanExecute(MailTemplateModel model) { return(model != null); }
public ResultOfType <MailTemplateModel> SendRendezVousVersOutlook(MailTemplateModel mail, string HDFrom, string HDTo) { return(_contactDomainServices.SendRendezVousVersOutlook(mail, HDFrom, HDTo)); }
public ResultOfType <MailTemplateModel> SendRendezVousVersOutlook(MailTemplateModel mail, string HDFrom, string HDTo) { try { #region Outlook ////First thing you need to do is add a reference to Microsoft Outlook 11.0 Object Library. Then, create new instance of Outlook.Application object: //OutlookApp outlookApp = new OutlookApp(); // creates new outlook app ////Next, create an instance of AppointmentItem object and set the properties: //var oAppointment = (AppointmentItem)outlookApp.CreateItem(OlItemType.olAppointmentItem); //oAppointment.Subject = mail.Subject; //oAppointment.Body = mail.Body; //oAppointment.Location = mail.AdressePraticien; //// Set the start date //oAppointment.Start = new DateTime(2015, 07, 20, 18, 0, 0); //// End date //oAppointment.End = new DateTime(2015, 07, 20, 19, 0, 0); //// Set the reminder 15 minutes before start //oAppointment.ReminderSet = true; //oAppointment.ReminderMinutesBeforeStart = 15; ////Setting the sound file for a reminder: ////set ReminderPlaySound = true; ////set ReminderSoundFile to a filename. ////Setting the importance: ////use OlImportance enum to set the importance to low, medium or high //oAppointment.Importance = OlImportance.olImportanceHigh; ///* OlBusyStatus is enum with following values: //olBusy //olFree //olOutOfOffice //olTentative //*/ //oAppointment.BusyStatus = OlBusyStatus.olBusy; ////Finally, save the appointment: //// Save the appointment //oAppointment.Save(); //// When you call the Save () method, the appointment is saved in Outlook. Another useful method is ForwardAsVcal () which can be used to send the Vcs file via email. //Outlook.MailItem mailItem = oAppointment.ForwardAsVcal(); //mailItem.To = mail.To; //mailItem.Send(); #endregion #region Dernier essai DateTime outputDateTimeValue; DateTime.TryParseExact(HDFrom, "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out outputDateTimeValue); DateTime outputDateTimeValue2; DateTime.TryParseExact(HDTo, "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out outputDateTimeValue2); string startTime1 = Convert.ToDateTime(outputDateTimeValue).ToString("yyyyMMddTHHmmssZ"); string endTime1 = Convert.ToDateTime(outputDateTimeValue2).ToString("yyyyMMddTHHmmssZ"); //SmtpClient sc = new SmtpClient("smtp.gmail.com") //{ // Port = 587, // Credentials = new NetworkCredential("*****@*****.**", "reb@i321"), // EnableSsl = true //}; MailMessage msg = new MailMessage { From = new MailAddress(mail.From, "This is the email from") }; msg.To.Add(new MailAddress(mail.To)); msg.Subject = mail.Subject; msg.Body = mail.Body; StringBuilder str = new StringBuilder(); str.AppendLine("BEGIN:VCALENDAR"); //PRODID: identifier for the product that created the Calendar object str.AppendLine("PRODID:-//ABC Company//Outlook MIMEDIR//EN"); str.AppendLine("VERSION:2.0"); str.AppendLine("METHOD:REQUEST"); str.AppendLine("BEGIN:VEVENT"); str.AppendLine(string.Format("DTSTART:{0:yyyyMMddTHHmmssZ}", startTime1)); //TimeZoneInfo.ConvertTimeToUtc("BeginTime").ToString("yyyyMMddTHHmmssZ"))); str.AppendLine(string.Format("DTSTAMP:{0:yyyyMMddTHHmmssZ}", DateTime.UtcNow)); str.AppendLine(string.Format("DTEND:{0:yyyyMMddTHHmmssZ}", endTime1)); //TimeZoneInfo.ConvertTimeToUtc("EndTime").ToString("yyyyMMddTHHmmssZ"))); str.AppendLine(string.Format("LOCATION: {0}", mail.AdressePraticien)); // UID should be unique. str.AppendLine(string.Format("UID:{0}", Guid.NewGuid())); str.AppendLine(string.Format("DESCRIPTION:{0}", msg.Body)); str.AppendLine(string.Format("X-ALT-DESC;FMTTYPE=text/html:{0}", msg.Body)); str.AppendLine(string.Format("SUMMARY:{0}", msg.Subject)); str.AppendLine("STATUS:CONFIRMED"); str.AppendLine("BEGIN:VALARM"); str.AppendLine("TRIGGER:-PT15M"); str.AppendLine("ACTION:Accept"); str.AppendLine("DESCRIPTION:Reminder"); str.AppendLine("X-MICROSOFT-CDO-BUSYSTATUS:BUSY"); str.AppendLine("END:VALARM"); str.AppendLine("END:VEVENT"); str.AppendLine(string.Format("ORGANIZER:MAILTO:{0}", msg.From.Address)); str.AppendLine(string.Format("ATTENDEE;CN=\"{0}\";RSVP=TRUE:mailto:{1}", msg.To[0].DisplayName, msg.To[0].Address)); str.AppendLine("END:VCALENDAR"); System.Net.Mime.ContentType ct = new System.Net.Mime.ContentType("text/calendar"); ct.Parameters.Add("method", "REQUEST"); ct.Parameters.Add("name", "meeting.ics"); AlternateView avCal = AlternateView.CreateAlternateViewFromString(str.ToString(), ct); msg.AlternateViews.Add(avCal); //Response.Write(str); // sc.ServicePoint.MaxIdleTime = 2; //sc.Send(msg); #endregion return(new Return <MailTemplateModel>().OK().WithResult(new MailTemplateModel { Body = mail.Body, From = mail.From, Subject = mail.Subject, To = mail.To })); } catch (System.Exception ex) { return(new Return <MailTemplateModel>().Error().As(EStatusDetail.BadRequest).AddingGenericError( null, "Erreur d'envoi de votre message vers outloook suite à l'exception : " + ex.Message + " ,Veuillez réessayer plus tard.").WithDefaultResult()); } //throw new NotImplementedException(); }
public async void LoadData() { IsBusy = true; _eventDataUnit.MailTemplatesRepository.Refresh(); var templates = await _eventDataUnit.MailTemplatesRepository.GetAllAsync(); MainEmailTemplate = new MailTemplateModel(templates.Where(x => x.MailTemplateCategory.Name == "Events" && x.MailTemplateType.Name == "MainEmailTemplate").FirstOrDefault()); MailTemplates = new ObservableCollection <MailTemplateModel>( templates.Where(x => x.MailTemplateCategory.Name == "Events" && x.IsEnabled && x.MailTemplateType.Name != "MainEmailTemplate").OrderBy(x => x.Name).Select(x => new MailTemplateModel(x))); _eventDataUnit.EmailHeadersRepository.Refresh(); var headers = await _eventDataUnit.EmailHeadersRepository.GetAllAsync(); _allEmailHeaders = new List <EmailHeader>(headers); EmailHeaders = new ObservableCollection <EmailHeader>(_allEmailHeaders.Where(x => x.IsEnabled)); var types = await _eventDataUnit.CorresponcenceTypesRepository.GetAllAsync(); _corresponcenceTypes = new List <CorresponcenceType>(types); var appPath = (string)ApplicationSettings.Read("DocumentsPath"); if (!_event.Reports.Any()) { var reports = await _eventDataUnit.ReportsRepository.GetAllAsync(x => x.EventID == _event.Event.ID); _event.Reports = new ObservableCollection <ReportModel>(reports.OrderByDescending(x => x.Date).Select(x => new ReportModel(x))); _event.RefreshReports(); } List <ReportModel> latestReports = _event.GetLatestReports(); //foreach (var report in latestReports) //{ // if (!_event.Documents.Select(x => x.Path).Contains(report.Report.Path)) // { // var document = new Document() // { // ID = Guid.NewGuid(), // EventID = _event.Event.ID, // Path = report.Report.Path, // Name = Path.GetFileNameWithoutExtension(report.Report.Path), // IsEnabled = true, // IsCommon = false // }; // _event.Documents.Add(document); // } //} var commonDocumets = await _eventDataUnit.DocumentsRepository.GetAllAsync(x => x.IsEnabled && x.IsCommon); Documents = new ObservableCollection <Document>(commonDocumets.Where(x => File.Exists(string.Concat(appPath, x.Path)))); foreach (var report in latestReports) { var eventDocument = _event.Documents.Where(doc => doc.Path == report.Report.Path).FirstOrDefault(); if (eventDocument == null) { eventDocument = new Document() { ID = report.Report.ID, EventID = _event.Event.ID, Path = report.Report.Path, Name = Path.GetFileNameWithoutExtension(report.Report.Path), IsEnabled = true, IsCommon = false }; } Documents.Add(eventDocument); } OnLoadContacts(); IsBusy = false; }