Пример #1
0
        private void ExecuteDeleteMember()
        {
            MessageBoxResult result = MessageBox.Show("Are you sure to delete " + currentMember.MemberName, "Delete", MessageBoxButton.YesNo, MessageBoxImage.Warning);

            if (result == MessageBoxResult.Yes)
            {
                if (currentMember != null)
                {
                    using (var unitofWork = new UnitOfWork(new MahalluDBContext())) {
                        ResidenceMember member = unitofWork.ResidenceMembers.Get(CurrentMember.Id);
                        if (member != null)
                        {
                            unitofWork.ResidenceMembers.Remove(member);
                            unitofWork.Complete();

                            ResidenceMemberType residenceMemberType = new ResidenceMemberType {
                                ResidenceMember = CurrentMember,
                                Operation       = MahalluManager.Model.Common.Operation.Delete
                            };
                            eventAggregator.GetEvent <PubSubEvent <ResidenceMemberType> >().Publish(residenceMemberType);

                            MemberList.Remove(CurrentMember);
                            CurrentMember = null;
                        }
                    }
                }
            }
        }
Пример #2
0
        private void ExecuteSaveMember()
        {
            using (var unitOfWork = new UnitOfWork(new MahalluDBContext())) {
                if (ValidateResidenceMember(unitOfWork))
                {
                    ResidenceMember residenceMember = GetResidenceMember();
                    if (CurrentMember != null)
                    {
                        CurrentMember.MemberName     = residenceMember.MemberName.ToUpper();
                        CurrentMember.DOB            = residenceMember.DOB;
                        CurrentMember.Job            = residenceMember.Job;
                        CurrentMember.Mobile         = residenceMember.Mobile;
                        CurrentMember.Abroad         = residenceMember.Abroad;
                        CurrentMember.Country        = residenceMember.Country;
                        CurrentMember.IsGuardian     = residenceMember.IsGuardian;
                        CurrentMember.MarriageStatus = residenceMember.MarriageStatus;
                        CurrentMember.Qualification  = residenceMember.Qualification;
                        CurrentMember.Remarks        = residenceMember.Remarks;
                        CurrentMember.Gender         = residenceMember.Gender;
                        unitOfWork.ResidenceMembers.Update(CurrentMember);
                        MessageBox.Show(CurrentMember.MemberName + " updated successfully !", "New Member", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                    else
                    {
                        unitOfWork.ResidenceMembers.Add(residenceMember);
                        MemberList.Add(residenceMember);
                        CurrentMember = residenceMember;
                        MessageBox.Show(CurrentMember.MemberName + " added successfully !", "New Member", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                    unitOfWork.Complete();

                    ResidenceMemberType residenceMemberType = new ResidenceMemberType {
                        ResidenceMember = CurrentMember,
                        Operation       = MahalluManager.Model.Common.Operation.Add
                    };
                    eventAggregator.GetEvent <PubSubEvent <ResidenceMemberType> >().Publish(residenceMemberType);
                }
            }
        }