示例#1
0
        private async void SubmitCommandExecuted()
        {
            IsBusy = true;

            if (_isResend)
            {
                var mail = GetCorrespondence();
                mail.CCAddress           = Correspondence.CCAddress;
                mail.Date                = DateTime.Now;
                mail.FromAddress         = Correspondence.FromAddress;
                mail.ToAddress           = Correspondence.ToAddress;
                mail.Message             = Correspondence.Message;
                mail.SendMailToCcAddress = Correspondence.SendMailToCcAddress;
                mail.Subject             = Correspondence.Subject;
                mail.EmailType           = Correspondence.EmailType;
                mail.Correspondence.CorresponcenceTypeID = Correspondence.Correspondence.CorresponcenceTypeID;
                mail.ContactTo = Correspondence.ContactTo;

                Correspondence = mail;
            }
            else
            {
                var type = _corresponcenceTypes.FirstOrDefault(x => x.Type == "Event");
                Correspondence.CorresponcenceType = type;
                Correspondence.Message            = Correspondence.Message;
            }

            var onCompletedAction = new Action(() =>
            {
                if (Correspondence.SendMailToCcAddress)
                {
                    AddCCContacts();
                }

                foreach (var document in Correspondence.Documents)
                {
                    var correspondenceDocument = new CorrespondenceDocument()
                    {
                        ID = Guid.NewGuid(),
                        CorrespondenceID = Correspondence.Correspondence.ID,
                        DocumentID       = document.ID
                    };

                    _crmDataUnit.CorrespondenceDocumentsRepository.Add(correspondenceDocument);
                }

                // add entry into update log
                var update = new EnquiryUpdate()
                {
                    ID        = Guid.NewGuid(),
                    EnquiryID = _enquiry.Enquiry.ID,
                    Date      = DateTime.Now,
                    Message   = string.Format("Email was sent to {0}", _correspondence.ToAddress),
                    UserID    = AccessService.Current.User.ID
                };

                _enquiry.EnquiryUpdates.Insert(0, update);
                _crmDataUnit.EnquiryUpdatesRepository.Add(update);

                _enquiry.Correspondences.Insert(0, Correspondence);
                _crmDataUnit.CorresponcencesRepository.Add(Correspondence.Correspondence);
            });

            bool success = await EmailService.SendEmail(Correspondence, onCompletedAction, MainEmailTemplate.MailTemplate.Template);

            IsBusy = false;
            if (success)
            {
                RaisePropertyChanged("CloseDialog");
            }
        }
示例#2
0
        private async void SubmitCommandExecuted()
        {
            IsBusy = true;

            if (!_isResend)
            {
                var type = _corresponcenceTypes.FirstOrDefault(x => x.Type == "Event");
                Correspondence.CorresponcenceType = type;
            }

            var onCompleteAction = new Action(() =>
            {
                if (Correspondence.SendMailToCcAddress)
                {
                    AddCCContacts();
                }

                foreach (var document in Correspondence.Documents)
                {
                    var correspondenceDocument = new CorrespondenceDocument()
                    {
                        ID = Guid.NewGuid(),
                        CorrespondenceID = Correspondence.Correspondence.ID,
                        DocumentID       = document.ID
                    };

                    _eventDataUnit.CorrespondenceDocumentsRepository.Add(correspondenceDocument);
                }

                // add entry into update log
                var update = new EventUpdate()
                {
                    ID       = Guid.NewGuid(),
                    EventID  = _event.Event.ID,
                    Date     = DateTime.Now,
                    Message  = string.Format("Email was sent to {0}", _correspondence.ToAddress),
                    UserID   = AccessService.Current.User.ID,
                    OldValue = null,
                    NewValue = _correspondence.ToAddress,
                    ItemId   = _correspondence.Correspondence.ID,
                    ItemType = "Correspondence",
                    Field    = "Email",
                    Action   = UpdateAction.Added
                };

                _event.EventUpdates.Insert(0, update);
                _eventDataUnit.EventUpdatesRepository.Add(update);

                _event.Correspondences.Insert(0, Correspondence);
                _eventDataUnit.CorresponcencesRepository.Add(Correspondence.Correspondence);
            });

            bool success = await EmailService.SendEmail(Correspondence, onCompleteAction, MainEmailTemplate.MailTemplate.Template);

            IsBusy = false;

            if (success)
            {
                RaisePropertyChanged("CloseDialog");
            }
        }