예제 #1
0
 /// <summary>
 /// Deprecated Method for adding a new object to the MembershipUpdates EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToMembershipUpdates(MembershipUpdate membershipUpdate)
 {
     base.AddObject("MembershipUpdates", membershipUpdate);
 }
예제 #2
0
 /// <summary>
 /// Create a new MembershipUpdate object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="memberID">Initial value of the MemberID property.</param>
 /// <param name="userID">Initial value of the UserID property.</param>
 /// <param name="message">Initial value of the Message property.</param>
 /// <param name="date">Initial value of the Date property.</param>
 public static MembershipUpdate CreateMembershipUpdate(global::System.Guid id, global::System.Guid memberID, global::System.Guid userID, global::System.String message, global::System.DateTime date)
 {
     MembershipUpdate membershipUpdate = new MembershipUpdate();
     membershipUpdate.ID = id;
     membershipUpdate.MemberID = memberID;
     membershipUpdate.UserID = userID;
     membershipUpdate.Message = message;
     membershipUpdate.Date = date;
     return membershipUpdate;
 }
예제 #3
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");
        }
예제 #4
0
 public MembershipUpdateModel(MembershipUpdate membershipUpdate)
 {
     MembershipUpdate = membershipUpdate;
     MembershipUpdatesHistory = new List<MembershipUpdatesHistoryModel>();
 }
예제 #5
0
 private static MembershipUpdate ProcessMembershipUpdate(MemberModel memberModel, string message, string oldValue, string newValue, Guid itemID, string itemType, string field, UpdateAction action)
 {
     var update = new MembershipUpdate()
     {
         ID = Guid.NewGuid(),
         Date = DateTime.Now,
         MemberID = memberModel.Member.ID,
         UserID = AccessService.Current.User.ID,
         Message = message,
         OldValue = oldValue,
         NewValue = newValue,
         ItemId = itemID,
         ItemType = itemType,
         Field = field,
         Action = Convert.ToInt32(action)
     };
     return update;
 }