示例#1
0
        public SendEventMailView(EventModel model, CorrespondenceModel correspondence = null)
        {
            InitializeComponent();

            //ClipboardEx.ClipboardHandlers.Clear();

            //ClipboardHandler clipboardHandlerRtf = new ClipboardHandler();
            //clipboardHandlerRtf.ClipboardDataFormat = DataFormats.Rtf;
            //clipboardHandlerRtf.DocumentFormatProvider = new RtfFormatProvider();

            //ClipboardHandler clipboardHandlerHtml = new ClipboardHandler();
            //clipboardHandlerHtml.ClipboardDataFormat = DataFormats.Html;
            //clipboardHandlerHtml.DocumentFormatProvider = new HtmlFormatProvider();

            //ClipboardHandler clipboardHandlerText = new ClipboardHandler();
            //clipboardHandlerText.ClipboardDataFormat = DataFormats.Text;
            //clipboardHandlerText.DocumentFormatProvider = new TxtFormatProvider();

            //ClipboardEx.ClipboardHandlers.Add(clipboardHandlerRtf);
            //ClipboardEx.ClipboardHandlers.Add(clipboardHandlerHtml);
            //ClipboardEx.ClipboardHandlers.Add(clipboardHandlerText);

            DataContext = ViewModel = new SendEventMailViewModel(model, correspondence);

            ViewModel.PropertyChanged += ViewModelOnPropertyChanged;

            Owner = Application.Current.MainWindow;

            Loaded += OnSendEmailViewLoaded;
        }
示例#2
0
         public EmailView(CorrespondenceModel correspondence)
        {
            InitializeComponent();
            DataContext = _viewModel = new EmailViewModel(correspondence);

            Owner = Application.Current.MainWindow;
        }
示例#3
0
 public SendEmailPreView(CorrespondenceModel correspondence, string message, string mainTemplate = null)
 {
     InitializeComponent();
     DataContext = _viewModel = new SendEmailPreViewModel(correspondence, message, mainTemplate);
     RadWindowInteropHelper.SetAllowTransparency(this, false);
     Loaded += SendEmailPreView_Loaded;
     Owner = Application.Current.MainWindow;
 }
        private void ShowCorrespondenceCommandExecuted(CorrespondenceModel obj)
        {
            RaisePropertyChanged("DisableParentWindow");

            var window = new SendEnquiryMailView(_enquiry, obj);
            window.ShowDialog();

            RaisePropertyChanged("EnableParentWindow");
        }
示例#5
0
        public SendEmailView(ObservableCollection<MemberModel> members, CorrespondenceModel correspondence = null)
        {
            InitializeComponent();
            DataContext = _viewModel = new SendEmailViewModel(members, correspondence);
            _viewModel.PropertyChanged += ViewModelOnPropertyChanged;

            Loaded += OnSendEmailViewLoaded;
            Owner = Application.Current.MainWindow;
        }
示例#6
0
        public SendEnquiryMailView(EnquiryModel model, CorrespondenceModel correspondence = null)
        {
            InitializeComponent();
            DataContext = ViewModel = new SendEnquiryMailViewModel(model, correspondence);

            Owner = Application.Current.MainWindow;

            ViewModel.PropertyChanged += ViewModelOnPropertyChanged;

            Loaded += OnSendEnquiryViewLoaded;
        }
示例#7
0
        public SendEmailPreViewModel(CorrespondenceModel correspondence, string message, string mainTemplate)
        {
            if (mainTemplate != null)
            {
                String messageBody = mainTemplate;
                messageBody = messageBody
                    .Replace("{#EmailHeader}", correspondence.Correspondence.EmailHeader != null && correspondence.Correspondence.EmailHeader.Content != null ? correspondence.Correspondence.EmailHeader.Content : string.Empty)
                    .Replace("{#EmailFooter}", Properties.Settings.Default.CRMEmailFooter)
                    .Replace("{#TemplateColor}", HexColorCodeFromRGB(Properties.Settings.Default.CRMEmailTemplateColor))
                    .Replace("{#Date}", String.Format("{0:dddd dd MMMM}", DateTime.Now))
                    .Replace("{#InternalTemplate}", message);
                var appPath = (string)ApplicationSettings.Read("ImagesPath");
                if (string.IsNullOrWhiteSpace(appPath)) return;
                var fullPathHeaderImage = string.Concat(appPath, correspondence.Correspondence.EmailHeader != null && correspondence.Correspondence.EmailHeader.ImageName != null ? correspondence.Correspondence.EmailHeader.ImageName : string.Empty);
                var fullPathFooterImage = string.Concat(appPath, Properties.Settings.Default.CRMEmailFooterImage);

                if (File.Exists(fullPathHeaderImage))
                {
                    byte[] imageBytes = File.ReadAllBytes(fullPathHeaderImage);
                    messageBody = messageBody.Replace("{#HeaderImage}", fullPathHeaderImage);
                }
                else
                    messageBody = messageBody.Replace("<img src='{#HeaderImage}' border='0' width='580' alt='' />", string.Empty);
                if (File.Exists(fullPathFooterImage))
                {
                    byte[] imageBytes = File.ReadAllBytes(fullPathFooterImage);
                    messageBody = messageBody.Replace("{#FooterImage}", fullPathFooterImage);
                }
                else
                    messageBody = messageBody.Replace("<img src='{#FooterImage}' width='580' alt='' />", string.Empty);

                Message = messageBody;
            }
            else
                Message = message;
        }
示例#8
0
 public EmailViewModel(CorrespondenceModel mail)
 {         
     Correspondence = mail;
 }
示例#9
0
        private static bool PrepareAttachments(CorrespondenceModel model, MailMessage message)
        {
            var appPath = (string)ApplicationSettings.Read("DocumentsPath");

            if (string.IsNullOrWhiteSpace(appPath) || !model.Documents.Any()) return true;

            var response = false;
            foreach (var document in model.Documents)
            {
                var fullPath = string.Concat(appPath, document.Path);

                if (File.Exists(fullPath))
                {
                    var attachment = new Attachment(fullPath, MediaTypeNames.Application.Octet);
                    ContentDisposition disposition = attachment.ContentDisposition;
                    disposition.CreationDate = File.GetCreationTime(fullPath);
                    disposition.ModificationDate = File.GetLastWriteTime(fullPath);
                    disposition.ReadDate = File.GetLastAccessTime(fullPath);
                    disposition.FileName = Path.GetFileName(fullPath);
                    disposition.Size = new FileInfo(fullPath).Length;
                    disposition.DispositionType = DispositionTypeNames.Attachment;
                    message.Attachments.Add(attachment);
                    response = true;
                }
                else
                {
                    RadWindow.Alert(Resources.MESSAGE_DOCUMENT_NOT_FOUND);
                    response = false;
                }
            }
            return response;
        }
示例#10
0
        private async void SubmitCommandExecuted()
        {
            IsBusy = true;
            if (!_isResend)
            {
                Correspondence.CorresponcenceType = _corresponcenceType;
            }
             //   if (Correspondence.SaveOnClientsRecord)
            //    AddCorrespondenceOnMembersRecord();
          
            var membersEmailNotSent = new List<MemberModel>();

            foreach (var member in MembersHavingValidEmail)
            {
                var newMemberCorrespondence = new CorrespondenceModel(GetCorrespondenceByMember(member));
                bool success = await EmailService.SendEmail(newMemberCorrespondence, MainEmailTemplate.MailTemplate.Template);
                if (success)
                {
                    // add entry into update log
                    var update = new MembershipUpdate()
                    {
                        ID = Guid.NewGuid(),
                        MemberID = member.Member.ID,
                        Date = DateTime.Now,
                        Message = string.Format("Email was sent to {0}", member.Contact.Email),
                        UserID = AccessService.Current.User.ID,
                        OldValue = null,
                        NewValue = member.Contact.Email,
                        ItemId = newMemberCorrespondence.Correspondence.ID,
                        ItemType = "Correspondence",
                        Field = "Email",
                        Action = Convert.ToInt32(UpdateAction.Added)
                    };
                    // If false don't save Correspondence.
                    // Make ItemId = null;
                    if (!Correspondence.SaveOnClientsRecord)
                    {
                        update.ItemId = null;
                    }
                    _membershipDataUnit.MembershipUpdatesRepository.Add(update);
                }
                else
                {
                    membersEmailNotSent.Add(member);
                }
            }
            _membershipDataUnit.CorresponcencesRepository.RevertChanges(Correspondence.SaveOnClientsRecord);
           await _membershipDataUnit.SaveChanges();

            IsBusy = false;

            string confirmText = Members.Count + " members selected";

            confirmText = MembersHavingInvalidEmail.Count > 0 ?
                (confirmText + ", " + MembersHavingInvalidEmail.Count + " have no email addresses") : confirmText;

            confirmText = MembersHavingValidEmail.Except(membersEmailNotSent).Count() > 0 ? (confirmText + ", " + MembersHavingValidEmail.Except(membersEmailNotSent).Count() + " sent successfully") :

          confirmText = membersEmailNotSent.Count > 0 ? (confirmText + ", " + membersEmailNotSent.Count + " not sent due to error having following names :- " +
          
          string.Join("\n", membersEmailNotSent.Select(x => x.Contact.FirstName).ToArray())) : confirmText;

            RaisePropertyChanged("DisableParentWindow");

            RadWindow.Alert(new DialogParameters
                {
                    Owner = Application.Current.MainWindow,
                    Content = new TextBlock() { Text = confirmText, TextWrapping = TextWrapping.Wrap, Width = 300 }
                });

            RaisePropertyChanged("EnableParentWindow");

            RaisePropertyChanged("CloseDialog");
        }
示例#11
0
        private CorrespondenceModel CopyCorrespondence(CorrespondenceModel correspondence)
        {
            var model = new CorrespondenceModel(new Corresponcence()
            {
                ID = Guid.NewGuid(),
                Date = DateTime.Now,
                OwnerType = "Membership",
                EmailType = "Email",
                UserID = AccessService.Current.User.ID
            })
            {
                FromAddress = correspondence.FromAddress,
                ToAddress = correspondence.ToAddress,
                Message = correspondence.Message,
                Subject = correspondence.Subject,
                EmailType = correspondence.EmailType,
                CorresponcenceType = correspondence.CorresponcenceType
            };

            return model;
        }
示例#12
0
        private CorrespondenceModel GetCorrespondence()
        {
            Message = "";
            var model = new CorrespondenceModel(new Corresponcence()
            {
                ID = Guid.NewGuid(),
                Date = DateTime.Now,
                OwnerType = "Membership",
                EmailType = "Email",
                Message = "",
                FromAddress = AccessService.Current.User.EmailAddress,
                ToAddress = MembersHavingValidEmail.Select(member => member.Contact.Email).FirstOrDefault(),
                UserID = AccessService.Current.User.ID
            });

            return model;
        }
示例#13
0
        public SendEmailViewModel(ObservableCollection<MemberModel> members, CorrespondenceModel correspondence)
        {
            Members = members;

            string pattern = @"^(?!\.)(""([^""\r\\]|\\[""\r\\])*""|"
                                + @"([-a-z0-9!#$%&'*+/=?^_`{|}~]|(?<!\.)\.)*)(?<!\.)"
                                + @"@[a-z0-9][\w\.-]*[a-z0-9]\.[a-z][a-z\.]*[a-z]$";

            var regex = new Regex(pattern, RegexOptions.IgnoreCase);

            MembersHavingValidEmail = new ObservableCollection<MemberModel>(members.Where(member => !string.IsNullOrWhiteSpace(member.Contact.Email) && regex.IsMatch(member.Contact.Email)));

            MembersHavingInvalidEmail = new ObservableCollection<MemberModel>(members.Where(member => string.IsNullOrWhiteSpace(member.Contact.Email) || !regex.IsMatch(member.Contact.Email)));

            var dataUnitLocator = ContainerAccessor.Instance.GetContainer().Resolve<IDataUnitLocator>();
            _membershipDataUnit = dataUnitLocator.ResolveDataUnit<IMembershipDataUnit>();

            PreviewCommand = new RelayCommand(PreviewCommandExecuted, PreviewCommandCanExecute);
            SubmitCommand = new RelayCommand(SubmitCommandExecuted, SubmitCommandCanExecute);
            CancelCommand = new RelayCommand(CancelCommandExecuted);
            ProcessEmail(correspondence);
        }
示例#14
0
        private void OpenEmailCommandExecute(CorrespondenceModel model)
        {
            RaisePropertyChanged("DisableParentWindow");

            var window = new EmailView(model);
            window.ShowDialog();

            RaisePropertyChanged("EnableParentWindow");
        }
示例#15
0
        private async void SubmitCommandExecuted()
        {
            if (!_isEditMode)
            {
                FollowUp.TakenByUser = TakenByUser;
                FollowUp.AssignedToUser = AssignedToUser;
                if (AreEnquiriesVisible)
                {
                    FollowUp.FollowUp.Enquiry = SelectedEnquiry.Enquiry;

                }
                else if (!_isToDo)
                {
                    _enquiry.FollowUps.Add(FollowUp);
                }

                _crmDataUnit.FollowUpsRepository.Add(FollowUp.FollowUp);

                if (!_isToDo)
                {
                    var primaryContact = FollowUp.FollowUp.Enquiry != null ? FollowUp.FollowUp.Enquiry.Contact == null ? String.Empty : "Primary Contact: " + FollowUp.FollowUp.Enquiry.Contact.FirstName + " "
                        + FollowUp.FollowUp.Enquiry.Contact.LastName : String.Empty;

                    var msg = "Follow-Up" + "\n" + "Created by " + FollowUp.TakenByUser.FirstName + " " +
                              FollowUp.TakenByUser.LastName + " at " + DateTime.Now + "\n" +
                              "Event Name: " + FollowUp.EnquiryName + "\n" + primaryContact + "\n" + FollowUp.WhatToDo;
                    var email = new CorrespondenceModel(new Corresponcence()
                    {
                        ID = Guid.NewGuid(),
                        Date = DateTime.Now,
                        FromAddress = FollowUp.TakenByUser.EmailAddress,
                        ToAddress = FollowUp.AssignedToUser.EmailAddress,
                        Subject = "Follow-Up",
                        Message = msg,
                    });

                    await EmailService.SendEmail(email,null,null);
                    if (AreEnquiriesVisible)
                    {
                        _originalEnquiry = SelectedEnquiry.Clone();
                        _selectedEnquiry.FollowUps.Add(FollowUp);
                        var diff = LoggingService.FindDifference(_originalEnquiry, SelectedEnquiry, out ActivityChanged, out FoolowUpsChanged);
                        if (!SelectedEnquiry.EnquiryUpdates.Any())
                        {
                            var updates = await _crmDataUnit.EnquiryUpdatesRepository.GetAllAsync(x => x.EnquiryID == SelectedEnquiry.Enquiry.ID);
                            SelectedEnquiry.EnquiryUpdates = new ObservableCollection<EnquiryUpdate>(updates.OrderByDescending(x => x.Date));
                        }

                        ProcessUpdates(_selectedEnquiry, diff);
                        if (!_addToActivity)
                            await _crmDataUnit.SaveChanges();
                    }

                }
            }
            else
            {
                _followUp.AssignedToUser = AssignedToUser;
                _followUp.FollowUp.UserDueToDoID = AssignedToUser.ID;
                _followUp.FollowUp.LastEditDate = DateTime.Now;
                if (AreEnquiriesVisible)
                {
                    if (_originalEnquiry.Enquiry.ID != _selectedEnquiry.Enquiry.ID)
                    {

                        _originalEnquiry = _selectedEnquiry.Clone();
                    }

                    FollowUp.FollowUp.Enquiry = SelectedEnquiry.Enquiry;
                    SelectedEnquiry.FollowUps.Where(x => x.FollowUp == _followUp.FollowUp).FirstOrDefault().AssignedToUser = AssignedToUser;
                    var diff = LoggingService.FindDifference(_originalEnquiry, SelectedEnquiry, out ActivityChanged, out FoolowUpsChanged);
                    if (!SelectedEnquiry.EnquiryUpdates.Any())
                    {
                        var updates = await _crmDataUnit.EnquiryUpdatesRepository.GetAllAsync(x => x.EnquiryID == SelectedEnquiry.Enquiry.ID);
                        SelectedEnquiry.EnquiryUpdates = new ObservableCollection<EnquiryUpdate>(updates.OrderByDescending(x => x.Date));
                    }
                    ProcessUpdates(_selectedEnquiry, diff);

                    if (!_addToActivity)
                        await _crmDataUnit.SaveChanges();
                }
                else
                    _crmDataUnit.FollowUpsRepository.SetEntityModified(_followUp.FollowUp);
                FollowUp.Refresh();
            }
        }
示例#16
0
        public SendEventMailViewModel(EventModel eventModel, CorrespondenceModel mail)
        {
            _event = eventModel;

            var dataUnitLocator = ContainerAccessor.Instance.GetContainer().Resolve<IDataUnitLocator>();
            _eventDataUnit = dataUnitLocator.ResolveDataUnit<IEventDataUnit>();

            SubmitCommand = new RelayCommand(SubmitCommandExecuted, SubmitCommandCanExecute);
            CancelCommand = new RelayCommand(CancelCommandExecuted);

            ProcessMail(mail);
        }
示例#17
0
        private static void PrepareCcContacts(CorrespondenceModel correspondence, MailMessage message)
        {
            if (correspondence.SendMailToCcAddress && !string.IsNullOrWhiteSpace(correspondence.CCAddress))
            {
                string pattern = @"^(?!\.)(""([^""\r\\]|\\[""\r\\])*""|"
                                 + @"([-a-z0-9!#$%&'*+/=?^_`{|}~]|(?<!\.)\.)*)(?<!\.)"
                                 + @"@[a-z0-9][\w\.-]*[a-z0-9]\.[a-z][a-z\.]*[a-z]$";

                var regex = new Regex(pattern, RegexOptions.IgnoreCase);

                string[] emails = correspondence.CCAddress.Split(',');

                if (emails.Any())
                    emails.Where(email => !string.IsNullOrWhiteSpace(email) && regex.IsMatch(email))
                        .ForEach(message.To.Add);
            }
        }
示例#18
0
        private void ProcessMail(CorrespondenceModel mail)
        {
            _isResend = (mail != null);

            Correspondence = (_isResend) ? CopyCorrespondence(mail) : GetCorrespondence();
            Correspondence.PropertyChanged += MailOnPropertyChanged;
            this.PropertyChanged += SendEventMailViewModel_PropertyChanged;
        }
示例#19
0
        public static async Task<bool> SendEmail(CorrespondenceModel correspondence, string mainTemplate = null)
        {
            try
            {
                var settings = PrepareSettings();

                if (settings.HasErrors)
                {
                    PopupService.ShowMessage("Please check your SMTP settings in Admin module", MessageType.Failed);
                    return false;
                }

                using (var smtpClient = new SmtpClient(settings.Server))
                {
                    smtpClient.Port = 587;
                    smtpClient.EnableSsl = settings.EnableSsl;
                    smtpClient.UseDefaultCredentials = false;
                    smtpClient.Credentials = new NetworkCredential(settings.Username, settings.Password);

                    using (var message = new MailMessage())
                    {

                        message.From = new MailAddress(correspondence.FromAddress);
                        message.IsBodyHtml = true;
                        message.Subject = correspondence.Subject;
                        message.SubjectEncoding = Encoding.UTF8;

                        if (mainTemplate != null)
                        {
                            ApplyMainTemplate(correspondence.Message, mainTemplate, message, correspondence.Correspondence.EmailHeader);
                        }
                        else
                        {
                            message.Body = correspondence.Message;
                        }
                        message.BodyEncoding = Encoding.UTF8;
                        message.To.Add(correspondence.ToAddress);

                        await smtpClient.SendMailAsync(message);

                        return true;
                    }
                }
            }
            catch (Exception)
            {
                //PopupService.ShowMessage(ex.Message, MessageType.Failed);
                return false;
            }
        }
示例#20
0
        private CorrespondenceModel GetCorrespondence()
        {
            var model = new CorrespondenceModel(new Corresponcence()
            {
                ID = Guid.NewGuid(),
                Date = DateTime.Now,
                OwnerID = _event.Event.ID,
                OwnerType = "Event", // TODO: Remove
                EmailType = "Email",
                Message = "",
                FromAddress = AccessService.Current.User.EmailAddress,
                UserID = AccessService.Current.User.ID
            });

            if (_event.PrimaryContact != null)
            {
                model.ToAddress = _event.PrimaryContact.Contact.Email;
                model.ContactTo = _event.PrimaryContact;
                model.Correspondence.ContactToID = _event.PrimaryContact.Contact.ID;
            }

            return model;
        }
示例#21
0
        private void AddDefaultEventReminderCommandExecuted()
        {
            if (Event.EventType.EventTypeTODOs.Any())
            {
                Event.EventType.EventTypeTODOs.ToList().ForEach(async eventTypeTODO =>
                    {
                        var eventReminder = new EventReminderModel(new Data.Model.EventReminder()
                        {
                            ID = Guid.NewGuid(),
                            EventID = Event.Event.ID,
                            DateDue = eventTypeTODO.RelatedDateType == Convert.ToInt32(EventManagementSystem.Enums.Admin.RelatedDateType.EventDate) ? Event.Date.AddDays(eventTypeTODO.NumberOfDays) : Event.Event.CreationDate.AddDays(eventTypeTODO.NumberOfDays),
                            CreatedByUserID = AccessService.Current.User.ID,
                            WhatToDo = eventTypeTODO.WhatToDo,
                            Status = Convert.ToBoolean(Convert.ToInt32(EventManagementSystem.Enums.Events.ReminderStatus.Active)),
                            AssignedToUserID = eventTypeTODO.AssignedToUserID,
                            User = eventTypeTODO.User1,
                            EventTypeToDoID = eventTypeTODO.ID
                        });

                        Event.EventReminders.Add(eventReminder);
                        _eventDataUnit.EventRemindersRepository.Add(eventReminder.EventReminder);

                        var primaryContact = eventReminder.EventReminder.Event != null ? eventReminder.EventReminder.Event.Contact == null ? String.Empty : "Primary Contact: " + eventReminder.EventReminder.Event.Contact.FirstName + " "
                  + eventReminder.EventReminder.Event.Contact.LastName : String.Empty;

                        var msg = "Default Event Reminder" + "\n" + "Created by " + eventReminder.CreatedByUser.FirstName + " " +
                                  eventReminder.CreatedByUser.LastName + " at " + DateTime.Now + "\n" +
                                  "Event Name: " + eventReminder.EventName + "\n" + primaryContact + "\n" + eventReminder.WhatToDo;
                        var email = new CorrespondenceModel(new Corresponcence()
                        {
                            ID = Guid.NewGuid(),
                            Date = DateTime.Now,
                            FromAddress = eventReminder.CreatedByUser.EmailAddress,
                            ToAddress = eventReminder.AssignedToUser.EmailAddress,
                            Subject = "Default Event Reminder",
                            Message = msg,
                        });

                        await EmailService.SendEmail(email, null, null);
                    });
            }
        }
示例#22
0
        private CorrespondenceModel CopyCorrespondence(CorrespondenceModel correspondence)
        {
            var model = new CorrespondenceModel(new Corresponcence()
            {
                ID = Guid.NewGuid(),
                Date = DateTime.Now,
                OwnerID = _event.Event.ID,
                OwnerType = "Event", // TODO: Remove
                EmailType = "Email",
                UserID = AccessService.Current.User.ID
            })
            {
                CCAddress = correspondence.CCAddress,
                FromAddress = correspondence.FromAddress,
                ToAddress = correspondence.ToAddress,
                Message = correspondence.Message,
                SendMailToCcAddress = correspondence.SendMailToCcAddress,
                Subject = correspondence.Subject,
                EmailType = correspondence.EmailType,
                CorresponcenceType = correspondence.CorresponcenceType,
                ContactTo = correspondence.ContactTo
            };

            return model;
        }
示例#23
0
        private async void SubmitCommandExecuted()
        {
            if (!IsEditMode)
            {
                if (AreEventsVisible)
                {
                    EventReminder.EventReminder.EventID = SelectedEvent.Event.ID;
                    EventReminder.EventReminder.Event = SelectedEvent.Event;
                }
                else
                    _event.EventReminders.Add(EventReminder);
                _eventDataUnit.EventRemindersRepository.Add(EventReminder.EventReminder);

                var primaryContact = EventReminder.EventReminder.Event != null ? EventReminder.EventReminder.Event.Contact == null ? String.Empty : "Primary Contact: " + EventReminder.EventReminder.Event.Contact.FirstName + " "
                    + EventReminder.EventReminder.Event.Contact.LastName : String.Empty;

                var msg = "Event-Reminder" + "\n" + "Created by " + EventReminder.CreatedByUser.FirstName + " " +
                          EventReminder.CreatedByUser.LastName + " at " + DateTime.Now + "\n" +
                          "Event Name: " + EventReminder.EventName + "\n" + primaryContact + "\n" + EventReminder.WhatToDo;
                var email = new CorrespondenceModel(new Corresponcence()
                {
                    ID = Guid.NewGuid(),
                    Date = DateTime.Now,
                    FromAddress = EventReminder.CreatedByUser.EmailAddress,
                    ToAddress = EventReminder.AssignedToUser.EmailAddress,
                    Subject = "Event-Reminder",
                    Message = msg,
                });

                await EmailService.SendEmail(email, null, null);
                if (AreEventsVisible)
                {
                    _originalEvent = SelectedEvent.Clone();
                    SelectedEvent.EventReminders.Add(EventReminder);
                    var eventUpdates = LoggingService.FindDifference(_originalEvent, SelectedEvent);
                    if (!SelectedEvent.EventUpdates.Any())
                    {
                        var updates = await _eventDataUnit.EventUpdatesRepository.GetAllAsync(x => x.EventID == SelectedEvent.Event.ID);
                        SelectedEvent.EventUpdates = new ObservableCollection<EventUpdate>(updates.OrderByDescending(x => x.Date));
                    }
                    ProcessUpdates(SelectedEvent, eventUpdates);

                    await _eventDataUnit.SaveChanges();
                }
            }
            else
            {
                _eventReminder.AssignedToUser = AssignedToUser;
                _eventReminder.EventReminder.AssignedToUserID = AssignedToUser.ID;
                EventReminder.EventReminder.LastEditDate = DateTime.Now;
                if (AreEventsVisible)
                {
                    if (_originalEvent.Event.ID != _selectedEvent.Event.ID)
                    {
                        _originalEvent = _selectedEvent.Clone();
                    }

                    EventReminder.EventReminder.Event = SelectedEvent.Event;
                    SelectedEvent.EventReminders.Where(x => x.EventReminder == _eventReminder.EventReminder).FirstOrDefault().AssignedToUser = AssignedToUser;
                    var eventUpdates = LoggingService.FindDifference(_originalEvent, SelectedEvent);
                    if (!SelectedEvent.EventUpdates.Any())
                    {
                        var updates = await _eventDataUnit.EventUpdatesRepository.GetAllAsync(x => x.EventID == SelectedEvent.Event.ID);
                        SelectedEvent.EventUpdates = new ObservableCollection<EventUpdate>(updates.OrderByDescending(x => x.Date));
                    }
                    ProcessUpdates(_selectedEvent, eventUpdates);

                    await _eventDataUnit.SaveChanges();
                }
                else
                    _eventDataUnit.EventRemindersRepository.SetEntityModified(_eventReminder.EventReminder);
                EventReminder.Refresh();
            }

        }
示例#24
0
        private CorrespondenceModel GetCorrespondence()
        {
            var model = new CorrespondenceModel(new Corresponcence()
            {
                ID = Guid.NewGuid(),
                Date = DateTime.Now,
                OwnerID = _enquiry.Enquiry.ID,
                OwnerType = "Enquiry",
                EmailType = "Email",
                Message = "",
                FromAddress = AccessService.Current.User.EmailAddress,
                UserID = AccessService.Current.User.ID
            });

            if (_enquiry.PrimaryContact != null)
            {
                model.ToAddress = _enquiry.PrimaryContact.Contact.Email;
                model.ContactTo = _enquiry.PrimaryContact;
                model.Correspondence.ContactToID = _enquiry.PrimaryContact.Contact.ID;
            }

            if (_isResend)
                model.Documents = new ObservableCollection<Document>(Correspondence.Documents);

            return model;
        }