public ContributionListViewModel SortContributionListViewModel(ContributionListViewModel contributionListViewModel) { if (!(string.IsNullOrEmpty(contributionListViewModel.SortBy))) { if (contributionListViewModel.IsOrderBy) { contributionListViewModel.ContributionListsPageLists = SortContributionLists(contributionListViewModel.PageIndex, contributionListViewModel.PageSize, contributionListViewModel.Keyword, contributionListViewModel.SortBy, contributionListViewModel.CurrentSort); if (contributionListViewModel.SortBy.Equals(contributionListViewModel.CurrentSort)) { contributionListViewModel.CurrentSort = null; } else { contributionListViewModel.CurrentSort = contributionListViewModel.SortBy; } } else { contributionListViewModel.ContributionListsPageLists = SortContributionLists(contributionListViewModel.PageIndex, contributionListViewModel.PageSize, contributionListViewModel.Keyword, contributionListViewModel.SortBy, (string.IsNullOrEmpty(contributionListViewModel.CurrentSort)) ? contributionListViewModel.SortBy : null); } } else { contributionListViewModel.ContributionListsPageLists = EFContribution.GetContributionLists(contributionListViewModel.Keyword).OrderByDescending(c => c.ContributionID).ToPagedList(contributionListViewModel.PageIndex, contributionListViewModel.PageSize); } return(contributionListViewModel); }
/// <summary> /// 贡献表 /// </summary> /// <param name="PageIndex"></param> /// <param name="PageSize"></param> /// <param name="Keyword"></param> /// <returns></returns> public ActionResult ContributionListManage(int PageIndex = 1, int PageSize = 20, string Keyword = null, string SortBy = null, string CurrentSort = null, bool IsOrderBy = false) { DealViewBag("ContributionList"); contributionListViewModel = GetContributionListViewModel(PageIndex, PageSize, Keyword, SortBy, CurrentSort, IsOrderBy); if (Request.IsAjaxRequest()) { return(PartialView("_ContributionList", contributionListViewModel)); } return(View(contributionListViewModel)); }
/// <summary> /// 批量处理贡献表 /// </summary> /// <param name="ListID"></param> /// <param name="DealAction"></param> /// <param name="contributionListViewModel"></param> /// <returns></returns> public ActionResult DealContributionList(List <string> ListID, string DealAction, ContributionListViewModel contributionListViewModel) { if (ListID != null) { if (EFContribution.DealListContributionList(ListID, DealAction)) { contributionListViewModel = UpdateContributionListViewModel(contributionListViewModel); return(PartialView("_ContributionList", contributionListViewModel)); } } return(View(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)); }
/// <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)); }
/// <summary> /// 获取签到表视图 /// </summary> /// <param name="PageIdex"></param> /// <param name="PageSize"></param> /// <param name="Keyword"></param> /// <returns></returns> public ContributionListViewModel GetContributionListViewModel(int PageIdex, int PageSize, string Keyword, string SortBy, string CurrentSort, bool IsOrderBy) { contributionListViewModel = new ContributionListViewModel { ContributionListsPageLists = EFContribution.GetContributionLists(Keyword).OrderByDescending(c => c.ContributionID).ToPagedList(PageIdex, PageSize), PageIndex = PageIdex, PageSize = PageSize, Keyword = Keyword, CurrentSort = CurrentSort, SortBy = SortBy, IsOrderBy = IsOrderBy, }; contributionListViewModel = SortContributionListViewModel(contributionListViewModel); return(contributionListViewModel); }
/// <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)); }
/// <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 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)); }
/// <summary> /// 更新签到表视图 /// </summary> /// <param name="contributionListViewModel"></param> /// <returns></returns> public ContributionListViewModel UpdateContributionListViewModel(ContributionListViewModel contributionListViewModel) { contributionListViewModel = SortContributionListViewModel(contributionListViewModel); return(contributionListViewModel); }
public ActionResult GetAddContributionList(ContributionListViewModel contributionListViewModel) { contributionListViewModel.SignLists = EFSignInfo.signLists.Where(s => s.ContributionID == null).OrderByDescending(s => s.ContributionID).Take(10).ToList(); contributionListViewModel.MemberGroupLists = EFMemberGroup.MemberGroupLists.Where(m => m.ContributionID == null).OrderByDescending(m => m.MemberGroupID).Take(10).ToList(); return(PartialView("_AddContributionList", contributionListViewModel)); }