private void ExecuteDeleteContribution() { MessageBoxResult result = MessageBox.Show("Deleting Contribution will delete all of the details also, \nAre you sure to delete", "Delete", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (result == MessageBoxResult.Yes) { if (CurrentContribution != null) { using (var unitofWork = new UnitOfWork(new MahalluDBContext())) { MahalluManager.Model.Contribution contribution = unitofWork.Contributions.Get(CurrentContribution.Id); unitofWork.Contributions.Remove(contribution); unitofWork.Complete(); IncomeType incomeType = new IncomeType() { Contribution = CurrentContribution, Operation = MahalluManager.Model.Common.Operation.Delete }; eventAggregator.GetEvent <PubSubEvent <IncomeType> >().Publish(incomeType); ContributionList.Remove(CurrentContribution); CurrentContribution = null; } } } }
private MahalluManager.Model.Contribution GetContribution() { var contribution = new MahalluManager.Model.Contribution(); if (!Category.DetailsRequired) { contribution.ToatalAmount = Convert.ToDecimal(TotalAmount?.Trim()); } contribution.ReceiptNo = ContributionReceiptNumber?.Trim(); contribution.CategoryName = Category.Name?.Trim(); contribution.CreatedOn = CreatedOn; return(contribution); }
private void ExecuteSaveContribution() { if (ValidateContribution()) { using (var unitOfWork = new UnitOfWork(new MahalluDBContext())) { MahalluManager.Model.Contribution contribution = GetContribution(); unitOfWork.Contributions.Add(contribution); unitOfWork.Complete(); ContributionList.Add(contribution); CurrentContribution = contribution; IncomeType incomeType = new IncomeType() { Contribution = CurrentContribution }; eventAggregator.GetEvent <PubSubEvent <IncomeType> >().Publish(incomeType); } } }
private void ExecuteSearchContribution() { RefreshContribution(); searchSource = ContributionList.ToList();; if (SearchByYear) { ContributionList = new ObservableCollection <MahalluManager.Model.Contribution>(searchSource.FindAll((x) => x.CreatedOn.Year == Convert.ToInt32(SearchContributionText))); if (ContributionList != null && ContributionList.Count == 0) { MessageBox.Show("No Contribution Found in " + SearchContributionText); } } else if (SearchByHouseNumber) { int houseNumber; if (Int32.TryParse(SearchContributionText.Trim(), out houseNumber)) { using (var unitofWork = new UnitOfWork(new MahalluDBContext())) { List <ContributionDetail> tempContributionDetails = unitofWork.ContributionDetails.Find((x) => x.HouserNumber == houseNumber).ToList(); if (tempContributionDetails != null && tempContributionDetails.Count == 0) { MessageBox.Show("No Contribution Found with House number " + SearchContributionText); } else { ContributionList.Clear(); foreach (var item in tempContributionDetails) { MahalluManager.Model.Contribution contribution = searchSource.Find((x) => x.Id == item.Contribution_Id); if (contribution != null && !ContributionList.Contains(contribution)) { ContributionList.Add(contribution); } } } } } else { MessageBox.Show("Please enter house number"); } } else if (SearchByHouseName) { string houseName = SearchContributionText.Trim(); using (var unitofWork = new UnitOfWork(new MahalluDBContext())) { List <ContributionDetail> tempContributionDetails = unitofWork.ContributionDetails.Find((x) => x.HouserName.Contains(houseName)).ToList(); if (tempContributionDetails != null && tempContributionDetails.Count == 0) { MessageBox.Show("No Contribution Found with House name " + SearchContributionText); } else { ContributionList.Clear(); foreach (var item in tempContributionDetails) { MahalluManager.Model.Contribution contribution = searchSource.Find((x) => x.Id == item.Contribution_Id); if (contribution != null && !ContributionList.Contains(contribution)) { ContributionList.Add(contribution); } } } } } else if (SearchByMemberName) { string memberName = SearchContributionText.Trim(); using (var unitofWork = new UnitOfWork(new MahalluDBContext())) { List <ContributionDetail> tempContributionDetails = unitofWork.ContributionDetails.Find((x) => x.MemberName.Contains(memberName)).ToList(); if (tempContributionDetails != null && tempContributionDetails.Count == 0) { MessageBox.Show("No Contribution Found with Member name " + SearchContributionText); } else { ContributionList.Clear(); foreach (var item in tempContributionDetails) { MahalluManager.Model.Contribution contribution = searchSource.Find((x) => x.Id == item.Contribution_Id); if (contribution != null && !ContributionList.Contains(contribution)) { ContributionList.Add(contribution); } } } } } else if (SearchByCategory) { ContributionList = new ObservableCollection <MahalluManager.Model.Contribution>(searchSource.FindAll((x) => x.CategoryName == SearchContributionText)); if (ContributionList != null && ContributionList.Count == 0) { MessageBox.Show("No Contribution Found with " + SearchContributionText); } } }