public ActionResult DealContributionManageSave(List <int> GameID, List <decimal> AllContribution, string ContributionID) { int n = 0; decimal[] allContribution = AllContribution.ToArray(); foreach (var item in GameID) { if (allContribution[n] != 0 && allContribution[n] < 200) { Contribution contribution = EFContribution.Contributions.Where(c => c.ContributionID == ContributionID && c.GameID == item).FirstOrDefault(); if (contribution != null) { contribution.AllContribution = allContribution[n]; EFContribution.UpdateContribution(contribution); } } n++; } ContributionList contributionList = EFContribution.ContributionLists.Where(c => c.ContributionID == ContributionID).FirstOrDefault(); contributionViewModel = new ContributionViewModel { ContributionLists = EFContribution.ContributionLists.OrderByDescending(c => c.ContributionID).Take(10).ToList(), Contributions = EFContribution.Contributions.Where(c => c.ContributionID == ContributionID).OrderBy(c => c.GameID).ToList(), GameMembers = EFGameMember.gameMembers, ContributionList = contributionList, }; return(PartialView("_TabContent", contributionViewModel)); }
/// <summary> /// 删除签到表 /// </summary> /// <param name="signList"></param> /// <returns>true表示删除成功,false表示删除失败,不存在该表</returns> public bool DelSignList(SignList signList) { SignList signListResult = gameClubEntities.SignList.Where(s => s.SignID == signList.SignID).FirstOrDefault(); if (signListResult != null) { ContributionList contributionList = gameClubEntities.ContributionList.Where(c => c.ContributionID == signListResult.ContributionID).FirstOrDefault(); MemberGroupList memberGroupList = gameClubEntities.MemberGroupList.Where(m => m.MemberGroupID == signListResult.MemberGroupID).FirstOrDefault(); if (contributionList != null) { contributionList.SignID = null; } if (memberGroupList != null) { memberGroupList.SignID = null; } IEnumerable <SignInfo> signInfos = gameClubEntities.SignInfo.Where(s => s.SignID == signListResult.SignID); foreach (var item in signInfos) { gameClubEntities.SignInfo.Remove(item); } gameClubEntities.SignList.Remove(signListResult); gameClubEntities.SaveChanges(); EFUserRecord.AddUserOperateRecord("删除签到表ID为" + signList.SignID + "的签到表信息"); return(true); } else { return(false); } }
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; } } } }
/// <summary> /// 删除分组表 /// </summary> /// <param name="memberGroupList"></param> /// <returns></returns> public bool DelMemberGroupList(MemberGroupList memberGroupList) { MemberGroupList memberGroupListResult = gameClubEntities.MemberGroupList.Where(m => m.MemberGroupID == memberGroupList.MemberGroupID).FirstOrDefault(); if (memberGroupListResult != null) { SignList signList = gameClubEntities.SignList.Where(s => s.SignID == memberGroupList.SignID).FirstOrDefault(); ContributionList contributionList = gameClubEntities.ContributionList.Where(c => c.ContributionID == memberGroupList.ContributionID).FirstOrDefault(); IEnumerable <MemberGroup> memberGroups = gameClubEntities.MemberGroup.Where(m => m.MemberGroupID == memberGroupListResult.MemberGroupID); if (signList != null) { signList.MemberGroupID = null; } if (contributionList != null) { contributionList.MemberGroupID = null; } foreach (var item in memberGroups) { gameClubEntities.MemberGroup.Remove(item); } gameClubEntities.MemberGroupList.Remove(memberGroupListResult); gameClubEntities.SaveChanges(); EFUserRecord.AddUserOperateRecord("删除了ID为" + memberGroupList.MemberGroupID + "的分组表信息"); return(true); } return(false); }
public async Task <ContributionList> GetContributionsAsync(int offset = 0, int limit = 0) { // Let's fake some delay, to see all the fancy loaders! await Task.Delay(3000); // Take the local copy, which we sort of cached in this service. if (allContributionList != null) { return new ContributionList() { Contributions = allContributionList.Contributions.Skip(offset).Take(limit == 0 ? allContributionList.Contributions.Count : limit).ToList(), TotalContributions = allContributionList.Contributions.Count, PagingIndex = offset + limit > allContributionList.Contributions.Count ? allContributionList.Contributions.Count : offset + limit } } ; // Get them from "remote" aka reset the whole thing. var list = JsonConvert.DeserializeObject <List <Contribution> >(LocalResourceService.GetFile("getcontributions")); allContributionList = new ContributionList() { Contributions = list.OrderByDescending(x => x.StartDate).ToList(), TotalContributions = list.Count, PagingIndex = 0 }; return(new ContributionList() { Contributions = list.Skip(offset).Take(limit == 0 ? allContributionList.Contributions.Count : limit).ToList(), TotalContributions = list.Count, PagingIndex = 0 });; }
/// <summary> /// 更新签到表信息 /// </summary> /// <param name="signList"></param> /// <returns>true更新成功,false更新失败,不存在该签到表</returns> public bool UpdateSignList(SignList signList) { if (signList == null) { return(false); } SignList signListResult = gameClubEntities.SignList.Where(s => s.SignID == signList.SignID).FirstOrDefault(); if (signListResult != null) { if (signListResult.ContributionID != signList.ContributionID) { if (signListResult.ContributionID != null) { ContributionList contributionList = gameClubEntities.ContributionList.Where(c => c.ContributionID == signListResult.ContributionID).FirstOrDefault(); contributionList.SignID = null; } if (!string.IsNullOrEmpty(signList.ContributionID)) { ContributionList contributionList = gameClubEntities.ContributionList.Where(c => c.ContributionID == signList.ContributionID).FirstOrDefault(); contributionList.SignID = signList.SignID; } gameClubEntities.SaveChanges(); } if (signListResult.MemberGroupID != signList.MemberGroupID) { if (signListResult.MemberGroupID != null) { MemberGroupList memberGroupList = gameClubEntities.MemberGroupList.Where(m => m.MemberGroupID == signListResult.MemberGroupID).FirstOrDefault(); memberGroupList.SignID = null; } if (!string.IsNullOrEmpty(signList.MemberGroupID)) { MemberGroupList memberGroupList = gameClubEntities.MemberGroupList.Where(m => m.MemberGroupID == signList.MemberGroupID).FirstOrDefault(); memberGroupList.SignID = signList.SignID; } gameClubEntities.SaveChanges(); } signListResult.Active = signList.Active; signListResult.Type = signList.Type; signListResult.StartDateTime = signList.StartDateTime; signListResult.EndDateTime = signList.EndDateTime; signListResult.ContributionID = signList.ContributionID; signListResult.MemberGroupID = signList.MemberGroupID; gameClubEntities.SaveChanges(); EFUserRecord.AddUserOperateRecord("更新签到表ID为" + signList.SignID + "的签到表信息"); return(true); } else { return(false); } }
/// <summary> /// 更新贡献表 /// </summary> /// <param name="contributionList"></param> /// <param name="contributionListViewModel"></param> /// <returns></returns> public ActionResult UpdateContributionList(ContributionList contributionList, ContributionListViewModel contributionListViewModel) { if (ModelState.IsValid) { if (EFContribution.UpdateContributionList(contributionList)) { contributionListViewModel = UpdateContributionListViewModel(contributionListViewModel); return(PartialView("_ContributionList", contributionListViewModel)); } } return(View(false)); }
private void ExecuteClearSearchContribution() { if (searchSource != null && searchSource.Count != ContributionList.Count) { if (ContributionList != null) { ContributionList.Clear(); } searchSource = null; RefreshContribution(); } SearchContributionText = String.Empty; }
/// <summary> /// 获取某个贡献表 /// </summary> /// <param name="contributionList"></param> /// <param name="contributionListViewModel"></param> /// <returns></returns> public ActionResult GetContributionList(ContributionList contributionList, ContributionListViewModel contributionListViewModel) { ContributionList contributionListResult = EFContribution.ContributionList(contributionList.ContributionID); contributionListViewModel.SignLists = EFSignInfo.signLists.Where(s => s.ContributionID == null).OrderByDescending(s => s.SignID).Take(10).ToList(); contributionListViewModel.MemberGroupLists = EFMemberGroup.MemberGroupLists.Where(m => m.ContributionID == null).OrderByDescending(m => m.MemberGroupID).Take(10).ToList(); if (contributionListResult != null) { contributionListViewModel.ContributionList = contributionListResult; contributionListViewModel = UpdateContributionListViewModel(contributionListViewModel); return(PartialView("_EditContributionList", contributionListViewModel)); } return(View(false)); }
public ActionResult GetAddGameMember(ContributionList contributionList, ContributionViewModel contributionViewModel) { List <GameMember> gameMembers = new List <GameMember>(); IEnumerable <Contribution> contributions = EFContribution.Contributions.Where(c => c.ContributionID == contributionList.ContributionID); foreach (var item in EFGameMember.gameMembers.Where(g => g.IsDel != true).ToList()) { if (contributions.Where(c => c.GameID == item.GameID).FirstOrDefault() == null) { gameMembers.Add(item); } } contributionViewModel.GameMembers = gameMembers; return(PartialView("_GameMember", contributionViewModel)); }
/// <summary> /// 添加贡献表 /// </summary> /// <param name="contributionList"></param> /// <param name="contributionListViewModel"></param> /// <returns></returns> public ActionResult AddContributionList(ContributionList contributionList, ContributionListViewModel contributionListViewModel) { if (ModelState.IsValid) { if (EFContribution.AddContributionList(contributionList)) { SignList signList = EFSignInfo.signLists.Where(s => s.SignID == contributionList.SignID).FirstOrDefault(); MemberGroupList memberGroupList = EFMemberGroup.MemberGroupLists.Where(m => m.MemberGroupID == contributionList.MemberGroupID).FirstOrDefault(); if (signList != null && memberGroupList != null) { signList.ContributionID = contributionList.ContributionID; signList.MemberGroupID = contributionList.MemberGroupID; memberGroupList.ContributionID = contributionList.ContributionID; memberGroupList.SignID = contributionList.SignID; } else if (memberGroupList != null) { memberGroupList.ContributionID = contributionList.ContributionID; } else if (signList != null) { signList.ContributionID = contributionList.ContributionID; } EFSignInfo.UpdateSignList(signList); EFMemberGroup.UpdateMemberGroupList(memberGroupList); ViewBag.Success = "贡献表添加成功!"; contributionListViewModel = UpdateContributionListViewModel(contributionListViewModel); } else { ViewBag.Fault = "已存在该表!"; } } else { ViewBag.Fault = "请检查信息!"; } if (contributionListViewModel.ContributionListsPageLists == null) { contributionListViewModel = UpdateContributionListViewModel(contributionListViewModel); } return(PartialView("_ContributionList", contributionListViewModel)); }
public static IList <Grouping <int, Contribution> > ToGroupedContributions(this ContributionList list) { var result = new List <Grouping <int, Contribution> >(); DateTime periodStart = new DateTime(DateTime.Now.Year, 4, 1); // If we are before the 1st of April, the period start is last year's. if (DateTime.Now < periodStart) { periodStart = periodStart.AddYears(-1); } var thisPeriod = list.Contributions.Where(x => x.StartDate >= periodStart).OrderByDescending(x => x.StartDate); var lastPeriod = list.Contributions.Where(x => x.StartDate < periodStart).OrderByDescending(x => x.StartDate); result.Add(new Grouping <int, Contribution>(0, thisPeriod)); result.Add(new Grouping <int, Contribution>(1, lastPeriod)); return(result); }
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); } } }
public ActionResult ListActive(DateTime bDate, DateTime eDate, int memberID) { ViewBag.BeginDate = bDate; ViewBag.EndDate = eDate; ViewBag.CodeID = memberID; ViewBag.SearchType = ""; GetData(); IEnumerable<contribution> ContributionList; ContributionList = ContributionRepository.GetContributionByMemberDateRange(memberID, bDate.Date, eDate.Date).OrderByDescending(e => e.ContributionDate); ViewBag.RecordCount = ContributionList.Count(); foreach (var i in ContributionList) { i.FundName = ConstantRepository.GetConstantID(i.subCategoryID).Value1; i.member = MemberRepository.GetMemberByID(i.memberID); } decimal sum = ContributionList.Sum(e => e.Amount); ViewBag.Heading = string.Format("Total Contribution: {0:c}", sum); return PartialView(ContributionList); }
/// <summary> /// 删除贡献表 /// </summary> /// <param name="contributionList"></param> /// <param name="contributionListViewModel"></param> /// <returns></returns> public ActionResult DelContributionList(ContributionList contributionList, ContributionListViewModel contributionListViewModel) { if (ModelState.IsValid) { if (EFContribution.DelContributionList(contributionList)) { ViewBag.Success = "删除贡献表成功!"; contributionListViewModel = UpdateContributionListViewModel(contributionListViewModel); } else { ViewBag.Fault = "删除贡献表失败!"; } } if (contributionListViewModel.ContributionListsPageLists == null) { contributionListViewModel = UpdateContributionListViewModel(contributionListViewModel); } return(PartialView("_ContributionList", contributionListViewModel)); }
public ActionResult DealContributionManage(ContributionList contributionList) { DealViewBag("DealContributionManage"); if (string.IsNullOrEmpty(contributionList.ContributionID)) { contributionList = EFContribution.ContributionLists.OrderByDescending(c => c.ContributionID).FirstOrDefault(); } contributionViewModel = new ContributionViewModel { ContributionLists = EFContribution.ContributionLists.OrderByDescending(c => c.ContributionID).Take(10).ToList(), Contributions = EFContribution.Contributions.Where(c => c.ContributionID == contributionList.ContributionID).OrderBy(c => c.GameID).ToList(), GameMembers = EFGameMember.gameMembers, ContributionList = contributionList, }; if (Request.IsAjaxRequest()) { return(PartialView("_TabContent", contributionViewModel)); } return(View(contributionViewModel)); }
public ActionResult ImportContribution(HttpPostedFileBase file, string ContributionID, ContributionListViewModel contributionListViewModel) { DataTable dataTable = new DataTable(); var fileName = file.FileName; var filePath = Server.MapPath(string.Format("~/{0}", "Files")); string path = Path.Combine(filePath, fileName); file.SaveAs(path); dataTable = ImportExcel.GetExcelDataTable(path); if (dataTable.Rows.Count > 0) { GameClubEntities gameClubEntities = new GameClubEntities(); CovertListHelper toList = new CovertListHelper(); List <Contribution> contributions = toList.convertToList <Contribution>(dataTable); IEnumerable <Contribution> contributionsResult = gameClubEntities.Contribution.Where(c => c.ContributionID == ContributionID); ContributionList contributionList = gameClubEntities.ContributionList.Where(c => c.ContributionID == ContributionID).FirstOrDefault(); foreach (var item in contributions) { Contribution contribution = contributionsResult.Where(c => c.GameID == item.GameID).FirstOrDefault(); if (contribution != null) { if (item.AllContribution != null) { contribution.AllContribution = item.AllContribution; if (contributionList != null && contributionList.Time != null && contributionList.Time > 0) { contribution.MinSpeed = (contribution.AllContribution) / contributionList.Time * decimal.Parse("60"); } } } } gameClubEntities.SaveChanges(); } contributionListViewModel = UpdateContributionListViewModel(contributionListViewModel); return(PartialView("_ContributionList", contributionListViewModel)); }
public SummaryViewModel() { eventAggregator.GetEvent <PubSubEvent <SelectedYearType> >().Subscribe((e) => { Selected = ((SelectedYearType)e).SelectedYear; }); eventAggregator.GetEvent <PubSubEvent <IncomeType> >().Subscribe((e) => { IncomeType incomeType = (IncomeType)e; bool isPresent = false; Contribution temp = null; foreach (var item in ContributionList) { if (item.Id == incomeType.Contribution.Id) { item.ToatalAmount = incomeType.Contribution.ToatalAmount; isPresent = true; if (incomeType.Operation == MahalluManager.Model.Common.Operation.Delete) { temp = item; break; } } } if (temp != null) { contributionList.Remove(temp); } if (!isPresent) { ContributionList.Add(incomeType.Contribution); } TotalIncome = CalcuateTotalIncome(); }); eventAggregator.GetEvent <PubSubEvent <ExpenseType> >().Subscribe((e) => { ExpenseType expenseType = (ExpenseType)e; bool isPresent = false; Expense temp = null; foreach (var item in ExpenseList) { if (item.Id == expenseType.Expense.Id) { item.ToatalAmount = expenseType.Expense.ToatalAmount; isPresent = true; if (expenseType.Operation == MahalluManager.Model.Common.Operation.Delete) { temp = item; break; } } } if (temp != null) { ExpenseList.Remove(temp); } if (!isPresent) { ExpenseList.Add(expenseType.Expense); } TotalExpense = CalcuateTotalExpense(); }); Refresh(); Years = new ObservableCollection <string>(); SetYears(); }
public ActionResult List(DateTime bDate, DateTime eDate, int codeID = 0, string SearchType = "",string CallingMethod = "Details") { ViewBag.BeginDate = bDate; ViewBag.EndDate = eDate; ViewBag.CodeID = codeID; ViewBag.SearchType = SearchType; ViewBag.AllowEdit = false; if (ViewBag.CallingMethod == "Details") { ViewBag.AllowEdit = true; } GetData(); IEnumerable<contribution> ContributionList; ViewBag.Title = ""; ViewBag.DefaultSearch = false; if (SearchType == "MemberSearch") { ContributionList = ContributionRepository.GetContributionByMemberDateRange(codeID, bDate, eDate); member member = MemberRepository.GetMemberByID(codeID); spouse spouse1 = SpouseRepository.GetSpouseByID1(codeID); spouse spouse2 = SpouseRepository.GetSpouseByID2(codeID); if (spouse1 != null) { ViewBag.Title = string.Format("{0} Contributions ({1} - {2})", spouse1.JointTitheTitle, bDate.ToShortDateString(), eDate.ToShortDateString()); } else if (spouse2 != null) { ViewBag.Title = string.Format("{0} Contributions ({1} - {2})", spouse2.JointTitheTitle, bDate.ToShortDateString(), eDate.ToShortDateString()); } else { ViewBag.Title = string.Format("{0} Contributions ({1} - {2})", member.FullNameTitle, bDate.ToShortDateString(), eDate.ToShortDateString()); } } else if (SearchType == "FundSearch") { ViewBag.DefaultSearch = true; ContributionList = ContributionRepository.GetContributionByCategoryRange(codeID, bDate, eDate); constant category = ConstantRepository.GetConstantID(codeID); ViewBag.Title = string.Format("{0} Contributions ({1} - {2})", category.Value1, bDate.ToShortDateString(), eDate.ToShortDateString()); } else { ViewBag.DefaultSearch = true; ContributionList = ContributionRepository.GetContributionByDateRange(bDate, eDate); ViewBag.Title = string.Format("All Contributions ({0} - {1})", bDate.ToShortDateString(), eDate.ToShortDateString()); } ViewBag.RecordCount = ContributionList.Count(); foreach (var i in ContributionList) { i.FundName = ConstantRepository.GetConstantID(i.subCategoryID).Value1; i.member = MemberRepository.GetMemberByID(i.memberID); } decimal sum = ContributionList.Sum(e => e.Amount); ViewBag.Heading = string.Format("Total: {0:c}",sum); return PartialView(ContributionList); }
/// <summary> /// 添加签到表 /// </summary> /// <param name="signList"></param> /// <param name="signListViewModel"></param> /// <returns></returns> public ActionResult AddSignList(SignList signList, SignListViewModel signListViewModel, bool CreateContribution = false, bool CreateMemberGroup = false) { DealViewBag("SignList"); bool f = true; if (ModelState.IsValid) { if (signList.EndDateTime < signList.StartDateTime) { ViewBag.Fault = "结束时间不能小于开始时间!"; f = false; } if (f && signList.Active == true) { if (signList.StartDateTime < DateTime.Now && signList.EndDateTime < DateTime.Now) { ViewBag.Fault = "选定的时间起止范围请不要小于当前时间,除非把该表设为禁用状态 !"; f = false; } } if (f && !string.IsNullOrEmpty(signList.ContributionID)) { if (CreateContribution) { ViewBag.Fault = "不要同时选择和创建贡献表!"; f = false; } } else { if (CreateContribution) { signList.ContributionID = signList.SignID; } } if (f && !string.IsNullOrEmpty(signList.MemberGroupID)) { if (CreateMemberGroup) { ViewBag.Fault = "不要同时选择和创建分组表!"; f = false; } } else { if (CreateMemberGroup) { signList.MemberGroupID = signList.SignID; } } if (f) { signList.CreateTime = DateTime.Now; if (!string.IsNullOrEmpty(signList.ContributionID)) { ContributionList contributionList = new ContributionList { ContributionID = signList.ContributionID, Type = signList.Type, CreateDateTime = signList.CreateTime, }; EFContribution.AddContributionList(contributionList); } if (!string.IsNullOrEmpty(signList.MemberGroupID)) { MemberGroupList memberGroupList = new MemberGroupList { MemberGroupID = signList.MemberGroupID, Type = signList.Type, CreateDateTime = signList.CreateTime, }; EFMemberGroup.AddMemberGroupList(memberGroupList); } if (EFSignInfo.AddSignList(signList)) { if (signList.ContributionID != null) { ContributionList contributionListResult = EFContribution.ContributionList(signList.ContributionID); ContributionList contributionList = new ContributionList { ContributionID = contributionListResult.ContributionID, Type = contributionListResult.Type, CreateDateTime = contributionListResult.CreateDateTime, SignID = signList.SignID, MemberGroupID = signList.MemberGroupID }; EFContribution.UpdateContributionList(contributionList); } if (signList.MemberGroupID != null) { MemberGroupList memberGroupListResult = EFMemberGroup.MemberGroupList(signList.MemberGroupID); MemberGroupList memberGroupList = new MemberGroupList { MemberGroupID = memberGroupListResult.MemberGroupID, Type = memberGroupListResult.Type, CreateDateTime = memberGroupListResult.CreateDateTime, SignID = signList.SignID, ContributionID = signList.ContributionID, }; EFMemberGroup.UpdateMemberGroupList(memberGroupList); } signListViewModel = UpdateSignListViewModel(signListViewModel); ViewBag.Success = "添加签到表成功!"; } else { ViewBag.Fault = "添加签到表失败!"; f = false; } } } else { ViewBag.Fault = "输入数据有误!"; } if (!f) { signListViewModel = UpdateSignListViewModel(signListViewModel); } return(PartialView("_SignList", signListViewModel)); }
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); } } }
/// <summary> /// Gets the MVPs activities, depending on the offset (page) and the limit (number of items per-page) /// </summary> /// <param name="offset">page to return</param> /// <param name="limit">number of items for the page</param> /// <param name="forceRefresh">The result is cached in a backing list by default which prevents unnecessary fetches. If you want the cache refreshed, set this to true</param> /// <returns>A list of the MVP's contributions</returns> public async Task <ContributionList> GetContributionsAsync(int?offset, int limit, bool forceRefresh = false) { if (_contributionsCachedResult != null && !forceRefresh) { // Return the cached result by default. return(_contributionsCachedResult); } if (offset == null) { offset = 0; } try { using (var response = await _client.GetAsync($"contributions/{offset}/{limit}")) { if (response.IsSuccessStatusCode) { var json = await response.Content.ReadAsStringAsync(); var deserializedResult = JsonConvert.DeserializeObject <ContributionList>(json); // Update the cached result. _contributionsCachedResult = deserializedResult; return(_contributionsCachedResult); } if (response.StatusCode == HttpStatusCode.Unauthorized || response.StatusCode == HttpStatusCode.Forbidden) { AccessTokenExpired?.Invoke(this, new ApiServiceEventArgs { IsTokenRefreshNeeded = true }); } else if (response.StatusCode == HttpStatusCode.BadRequest) { var message = await response.Content.ReadAsStringAsync(); RequestErrorOccurred?.Invoke(this, new ApiServiceEventArgs { IsBadRequest = true, Message = message }); } } } catch (HttpRequestException e) { await e.LogExceptionAsync(); if (e.Message.Contains("500")) { RequestErrorOccurred?.Invoke(this, new ApiServiceEventArgs { IsServerError = true }); } Debug.WriteLine($"GetContributionsAsync HttpRequestException: {e}"); } catch (Exception e) { await e.LogExceptionAsync(); Debug.WriteLine($"GetContributionsAsync Exception: {e}"); } return(null); }