public async Task <IActionResult> Index() { int getCount = 4;//获取条目数 var datas = await this._anAssociationExtension.GetAll().Include(x => x.Avatar).ToListAsync(); var anAssociationRecommend = new List <AnAssociationVM>(); foreach (var item in datas) { var anVM = new AnAssociationVM(item); anVM.AnAssociationNum = (await _anAssociationAndUserExtension.GetAll().Where(x => x.AnAssociation.ID == item.ID).ToListAsync()).Count; anAssociationRecommend.Add(anVM); } var listAns = anAssociationRecommend.OrderByDescending(s => s.CreateDataTime).OrderByDescending(s => s.AnAssociationNum).Take(getCount).ToList(); ViewBag.ListAns = listAns; var userCount = 9;//默认获取9个人 var users = await _userExtension.GetAll().Include(s => s.Avatar).ToListAsync(); userCount = userCount > users.Count ? users.Count : userCount; //判断是否够9个人 var ran = new Random(); var index = 0; var interests = new List <ApplicationUser>();//用于存储随机相同兴趣的人 for (int i = 0; i < userCount; i++) { index = ran.Next(0, users.Count()); interests.Add(users[index]); users.RemoveAt(index); } ViewBag.InterestUsers = interests; return(View("~/Views/BusinessView/AnAssociationView/Index.cshtml")); }
public async Task <IActionResult> List(string keywork, string probably, string listPageParaJson) { var listPagePara = new ListPageParameter(); if (listPageParaJson != null) { listPagePara = Newtonsoft.Json.JsonConvert.DeserializeObject <ListPageParameter>(listPageParaJson); } var atCollection = new List <ActivityTerm>(); if (!String.IsNullOrEmpty(keywork)) { Expression <Func <ActivityTerm, bool> > condtion = x => x.Name.Contains(keywork) || x.User.Name.Contains(keywork) || x.AnAssociation.Name.Contains(keywork) || x.Address.Contains(keywork); atCollection = await _activityTermExtension.GetAll().Include(x => x.User).Include(x => x.AnAssociation).Include(x => x.Avatar).Where(condtion).Where(x => x.Status == ActivityStatus.未开始 && x.IsDisable).ToListAsync(); if (probably == "1") { atCollection = atCollection.Where(x => x.AnAssociation != null).ToList(); } else if (probably == "2") { atCollection = atCollection.Where(x => x.User != null && x.AnAssociation == null).ToList(); } } else { atCollection = await _activityTermExtension.GetAll().Include(x => x.User).Include(x => x.AnAssociation).Include(x => x.Avatar).Where(x => x.Status == ActivityStatus.未开始 && x.IsDisable).ToListAsync(); if (probably == "1") { atCollection = atCollection.Where(x => x.AnAssociation != null).ToList(); } else if (probably == "2") { atCollection = atCollection.Where(x => x.User != null && x.AnAssociation == null).ToList(); } } var activityTermPageList = IQueryableExtensions.ToPaginatedList(atCollection.AsQueryable(), listPagePara.PageIndex, 12); var activityCollections = new List <ActivityTermVM>(); foreach (var activityTermPage in activityTermPageList) { activityCollections.Add(new ActivityTermVM(activityTermPage) { EnteredNumber = (await _activityUserExtension.GetAll().Where(x => x.ActivityTermId == activityTermPage.ID).ToListAsync()).Count }); } var pageGroup = PagenateGroupRepository.GetItem(activityTermPageList, 5, listPagePara.PageIndex); ViewBag.PageGroup = pageGroup; ViewBag.PageParameter = listPagePara; return(View("~/Views/BusinessView/ActivityTermView/_List.cshtml", activityCollections)); }
/// <summary> /// 删除记录 /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task <IActionResult> DeleteActivityRecord(Guid id) { var entity = await _activityTermExtension.GetAll().Include(x => x.User).Where(x => x.ID == id).FirstOrDefaultAsync(); if (entity.User.Id != User.Claims.FirstOrDefault().Value) { return(Json(new { isOK = false, message = "删除失败,您没有权限操作" })); } if (entity == null) { return(Json(new { isOK = false, message = "删除失败,请联系管理员" })); } _activityTermExtension.DeleteAndSave(entity); return(Json(new { isOK = true, message = "删除历史活动成功" })); }
/// <summary> /// 根据ID查询对应的活动信息, /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task <IActionResult> Detail(Guid id) { var activityTerm = await _activityTermRepository.GetSingleAsyn(id, x => x.User, x => x.AnAssociation); var atVM = new ActivityTermVM(activityTerm); atVM.Images = await _businessImageRepository.GetAll().Where(x => x.RelevanceObjectID == id).ToListAsync(); //获取参与活动的用户 atVM.Members = await _activityUserExtension.GetAll().Include(x => x.User).Include(x => x.User.Avatar).Include(x => x.ActivityTerm).Where(x => x.ActivityTermId == id).ToListAsync(); ViewBag.MemberNumber = atVM.Members.Count(); ViewBag.CommentNumber = (await _commonExtension.GetAll().Include(x => x.Activity).Where(x => x.Activity.ID == id).ToListAsync()).Count(); return(PartialView("~/Views/GroupOrganization/ActivityTerm/_Detail.cshtml", atVM)); }
/// <summary> /// 根据关键词检索人员数据集合,返回给前端页面 /// </summary> /// <param name="keywork"></param> /// <returns></returns> public async Task <IActionResult> List(string keywork, string listPageParaJson, string pageIndex) { var listPagePara = new ListPageParameter(); if (listPageParaJson != null && listPageParaJson != "") { listPagePara = Newtonsoft.Json.JsonConvert.DeserializeObject <ListPageParameter>(listPageParaJson); } listPagePara.PageIndex = Convert.ToInt32(pageIndex); var boVMCollection = new List <ApplicationUserVM>(); if (!String.IsNullOrEmpty(keywork) && keywork != "undefined") { Expression <Func <ApplicationUser, bool> > condtion = x =>//Contains(参数字符串是否包含于string对象中) x.Name.Contains(keywork) || x.SchoolAddress.Contains(keywork) || x.School.Contains(keywork); var userCollection = await _userExtension.GetAll().Include(x => x.Avatar).Where(condtion).OrderByDescending(x => x.RegisterTime).ToListAsync(); foreach (var bo in userCollection) { boVMCollection.Add(new ApplicationUserVM(bo)); } } else { var userCollection = await _userExtension.GetAll().Include(x => x.Avatar).OrderByDescending(x => x.RegisterTime).ToListAsync(); foreach (var bo in userCollection) { boVMCollection.Add(new ApplicationUserVM(bo)); } } var userCollectionPageList = IQueryableExtensions.ToPaginatedList(boVMCollection.AsQueryable <ApplicationUserVM>(), listPagePara.PageIndex, listPagePara.PageSize); var userCollections = new List <ApplicationUserVM>(); foreach (var userCollection in userCollectionPageList) { userCollections.Add(userCollection); } var pageGroup = PagenateGroupRepository.GetItem <ApplicationUserVM>(userCollectionPageList, 3, listPagePara.PageIndex); ViewBag.PageGroup = pageGroup; ViewBag.PageParameter = listPagePara; return(View("~/Views/ApplicationOrganization/ApplicationUser/_List.cshtml", userCollections)); }
/// <summary> /// 删除活动图片 /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task <IActionResult> DeleteActivityDetailedImages(Guid id) { var entity = await _businessImageExtension.GetAll().Where(x => x.ID == id).FirstOrDefaultAsync(); _businessImageExtension.DeleteAndSave(entity); return(Json(new { isOk = true })); }
/// <summary> /// 以局部页的方式的方式,构建明细数据的处理 /// </summary> /// <param name="id">人员对象的ID属性值</param> /// <returns></returns> public async Task <IActionResult> Detail(Guid id) { var user = await _userExtension.GetAll().Include(x => x.Person).Where(x => x.Id == id.ToString()).FirstOrDefaultAsync(); var userVM = new ApplicationUserVM(user); //获取用户好友数量 var userFriens = await _userFriendExtension.GetAll().Where(x => x.UserID == id.ToString()).ToListAsync(); ViewBag.Friends = userFriens.Count; //获取社团数量 var anAssociations = await _anAssociationExtension.GetAll().Include(x => x.User).Where(x => x.User.Id == id.ToString()).ToListAsync(); var userAnAssociations = await _userAnAssociationExtension.GetAll().Include(x => x.User).Where(x => x.User.Id == id.ToString()).ToListAsync(); ViewBag.AnAssociations = anAssociations.Count + userAnAssociations.Count; //获取活动数量 var activitys = await _activityTermExtension.GetAll().Include(x => x.User).Where(x => x.User.Id == id.ToString() && x.Status == ActivityStatus.已结束).ToListAsync(); var userActivitys = await _activityUserExtension.GetAll().Include(x => x.User).Where(x => x.User.Id == id.ToString() && x.ActivityTerm.Status == ActivityStatus.已结束).ToListAsync(); ViewBag.Activitys = activitys.Count + userActivitys.Count; return(PartialView("~/Views/ApplicationOrganization/ApplicationUser/_Detail.cshtml", userVM)); }
public async Task <IActionResult> Index() { var user = User.Claims.FirstOrDefault(); if (user == null) { return(RedirectToAction("Error")); } var UserInfo = await _userExtension.GetSingleAsyn(x => x.Id == user.Value); if (UserInfo.Power == AnJurisdiction.Ordinary) { return(RedirectToAction("Error")); } var userCollection = await _userExtension.GetAll().Include(x => x.Avatar).OrderByDescending(x => x.RegisterTime).ToListAsync(); var users = userCollection.Take(10).ToList(); var userList = new List <ApplicationUserVM>(); foreach (var item in users) { userList.Add(new ApplicationUserVM(item)); } ViewBag.Users = userCollection.Count(); ViewBag.AnAssociations = (await _anAssociationExtension.GetAll().ToListAsync()).Count(); ViewBag.ActivityTerms = (await _activityTermExtension.GetAll().ToListAsync()).Count(); return(PartialView("Index", userList)); }
public async Task <IActionResult> Detailed(Guid id) { var entity = await _anAssociationRepository.GetSingleAsyn(id, x => x.User, x => x.User.Avatar, x => x.Avatar); //获取社团用户 var anAdminUsers = await _anAssociationAndUserExtension.GetAll().Include(x => x.User).Where(x => x.AnAssociationId == entity.ID).ToListAsync(); var AnAdmins = new List <ApplicationUser>(); //获取社团管理者 foreach (var item in anAdminUsers) { if (item.AnJurisdictionManager == AnJurisdiction.Admin) { AnAdmins.Add(await _userExtension.GetAll().Include(x => x.Avatar).Where(x => x.Id == item.User.Id).FirstOrDefaultAsync()); } } ViewBag.AnAdmins = AnAdmins; var entityVM = new AnAssociationVM(entity); var acNum = await _activityTermExtension.GetAll().Include(x => x.AnAssociation).Where(x => x.AnAssociation.ID == id).ToListAsync(); entityVM.acNum = acNum.Count; entityVM.userNum = anAdminUsers.Count(); return(View("~/Views/BusinessView/AnAssociationView/_Detailed.cshtml", entityVM)); }
/// <summary> /// 添加用户x => x.UserID == nowUser.Value && /// </summary> /// <returns></returns> public async Task <IActionResult> AddUser(Guid id) { var user = await _userManager.FindByIdAsync(id.ToString()); var nowUser = User.Claims.FirstOrDefault(); if (nowUser == null) { return(Json(new { isOK = false, message = "您未登录,请登录后再执行该操作" })); } if (nowUser.Value == id.ToString()) { return(Json(new { isOK = false, message = "不可添加自己为好友" })); } if (user == null) { return(Json(new { isOK = false, message = "好友添加失败,不存在这个用户" })); } var entity = await _userFriendExtension.GetAll().Include(x => x.Friend).Where(x => x.Friend.Id == id.ToString() && x.UserID.ToString() == nowUser.Value).FirstOrDefaultAsync(); if (entity != null) { return(Json(new { isOK = false, message = "你的好友列表里已存在该用户,不可重复添加" })); } var userFriend = new UserFriend() { UserID = nowUser.Value, Friend = user }; _userFriendExtension.AddAndSave(userFriend); return(Json(new { isOK = true, message = "添加成功" })); }
public async Task <IActionResult> Index() { var atCollection = await _activityTermExtension.GetAll().OrderBy(x => x.Status).ThenByDescending(x => x.CreateDateTime).Include(x => x.User).ToListAsync(); var atVmCollection = new List <ActivityTermVM>(); foreach (var at in atCollection) { var atVM = new ActivityTermVM(at); atVmCollection.Add(atVM); } var pageSize = 10; var pageIndex = 1; var activityTermList = atVmCollection.FirstOrDefault(); var activityTermCollections = new List <ActivityTermVM>(); //处理分页 var activityTermCollectionPageList = IQueryableExtensions.ToPaginatedList(atVmCollection.AsQueryable <ActivityTermVM>(), pageIndex, pageSize); foreach (var activityTermCollection in activityTermCollectionPageList) { activityTermCollections.Add(activityTermCollection); } //提取当前分页关联的分页器实例 var pageGroup = PagenateGroupRepository.GetItem(activityTermCollectionPageList, 5, pageIndex); ViewBag.PageGroup = pageGroup; var listPageParameter = new ListPageParameter() { PageIndex = activityTermCollectionPageList.PageIndex, Keyword = "", PageSize = activityTermCollectionPageList.PageSize, ObjectTypeID = "", ObjectAmount = activityTermCollectionPageList.TotalCount, SortDesc = "Default", SortProperty = "Name", PageAmount = 0, SelectedObjectID = "" }; ViewBag.PageParameter = listPageParameter; return(View("~/Views/GroupOrganization/ActivityTerm/Index.cshtml", activityTermCollections)); }
public async Task <IActionResult> Index() { var boCollection = await _hobbyExtension.GetAll().Include(x => x.Avatar).OrderBy(x => x.SortCode).ToListAsync(); var boVMCollection = new List <HobbyVM>(); foreach (var bo in boCollection) { var boVM = new HobbyVM(bo); boVMCollection.Add(boVM); } var pageSize = 10; var pageIndex = 1; var personList = boVMCollection.OrderBy(x => x.Name).FirstOrDefault(); // 处理分页 var hobbyCollectionPageList = IQueryableExtensions.ToPaginatedList(boVMCollection.AsQueryable <HobbyVM>(), pageIndex, pageSize); var hobbyCollections = new List <HobbyVM>(); foreach (var hobbyCollection in hobbyCollectionPageList) { hobbyCollections.Add(hobbyCollection); } //提取当前分页关联的分页器实例 var pageGroup = PagenateGroupRepository.GetItem <HobbyVM>(hobbyCollectionPageList, 5, pageIndex); ViewBag.PageGroup = pageGroup; var listPageParameter = new ListPageParameter() { PageIndex = hobbyCollectionPageList.PageIndex, Keyword = "", PageSize = hobbyCollectionPageList.PageSize, ObjectTypeID = "", ObjectAmount = hobbyCollectionPageList.TotalCount, SortDesc = "Default", SortProperty = "Name", PageAmount = 0, SelectedObjectID = "" }; ViewBag.PageParameter = listPageParameter; return(View("~/Views/ApplicationOrganization/Hobbys/Index.cshtml", hobbyCollections)); }
public async Task <IActionResult> List(string keywork, string listPageParaJson) { var listPagePara = new ListPageParameter(); if (listPageParaJson != null) { listPagePara = Newtonsoft.Json.JsonConvert.DeserializeObject <ListPageParameter>(listPageParaJson); } var anCollection = new List <AnAssociation>(); if (!String.IsNullOrEmpty(keywork)) { Expression <Func <AnAssociation, bool> > condtion = x => x.Name.Contains(keywork) || x.User.Name.Contains(keywork) || x.SchoolAddress.Contains(keywork); anCollection = await _anAssociationExtension.GetAll().Include(x => x.User).Include(x => x.Avatar).Where(condtion).Where(x => x.IsDisable).ToListAsync(); } else { anCollection = await _anAssociationExtension.GetAll().Include(x => x.User).Include(x => x.Avatar).Where(x => x.IsDisable).ToListAsync(); } var activityTermPageList = IQueryableExtensions.ToPaginatedList(anCollection.AsQueryable(), listPagePara.PageIndex, 12); var anAssociationCollections = new List <AnAssociationVM>(); foreach (var activityTermPage in activityTermPageList) { var anNum = await _anAssociationAndUserExtension.GetAll().Where(x => x.AnAssociationId == activityTermPage.ID).Select(x => x.AnAssociation).ToListAsync(); anAssociationCollections.Add(new AnAssociationVM(activityTermPage) { AnAssociationNum = anNum.Count() }); } var pageGroup = PagenateGroupRepository.GetItem(activityTermPageList, 5, listPagePara.PageIndex); ViewBag.PageGroup = pageGroup; ViewBag.PageParameter = listPagePara; return(View("~/Views/BusinessView/AnAssociationView/_List.cshtml", anAssociationCollections)); }
/// <summary> /// 根据关键词检索活动数据集合,返回给前端页面 /// </summary> /// <param name="keywork"></param> public async Task <IActionResult> List(string keywork, string listPageParaJson) { var listPagePara = Newtonsoft.Json.JsonConvert.DeserializeObject <ListPageParameter>(listPageParaJson); var anVMCollection = new List <AnAssociationVM>(); if (!String.IsNullOrEmpty(keywork) && keywork != "undefined") { Expression <Func <AnAssociation, bool> > condtion = x => x.Name.Contains(keywork) || x.SchoolAddress.Contains(keywork); var anAssociationCollection = await _anAssociationExtension.GetAll().Include(x => x.User).Where(condtion).ToListAsync(); foreach (var an in anAssociationCollection) { anVMCollection.Add(new AnAssociationVM(an)); } } else { var anAssociationCollection = await _anAssociationExtension.GetAllIncludingAsyn(x => x.User); foreach (var an in anAssociationCollection) { anVMCollection.Add(new AnAssociationVM(an)); } } var anAssociationPageList = IQueryableExtensions.ToPaginatedList(anVMCollection.AsQueryable(), listPagePara.PageIndex, listPagePara.PageSize); var associationCollections = new List <AnAssociationVM>(); foreach (var anAssociationPage in anAssociationPageList) { associationCollections.Add(anAssociationPage); } var pageGroup = PagenateGroupRepository.GetItem(anAssociationPageList, 5, listPagePara.PageIndex); ViewBag.PageGroup = pageGroup; ViewBag.PageParameter = listPagePara; return(View("~/Views/GroupOrganization/AnAssociation/_List.cshtml", associationCollections)); }
/// <summary> /// 获取活动评论 /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task <IActionResult> GetComments(Guid id, string listPageParaJson) { var listPagePara = new ListPageParameter(); if (listPageParaJson != null) { listPagePara = Newtonsoft.Json.JsonConvert.DeserializeObject <ListPageParameter>(listPageParaJson); } ViewBag.activityId = id; //获取一级评论 var commentList = await _commonExtension.GetAll().OrderByDescending(x => x.CommentDataTime).Include(x => x.Activity).Include(x => x.User).Include(x => x.User.Avatar).Where(x => x.Activity.ID == id && x.ParentGrade == null).ToListAsync(); var comments = new List <CommentVM>(); foreach (var item in commentList) { var commentVM = new CommentVM(item); commentVM.CommentChildrens = await _commonExtension.GetAll().OrderBy(x => x.CommentDataTime).Include(x => x.Activity).Include(x => x.AcceptUser).Include(x => x.User).Include(x => x.User.Avatar).Where(x => x.ParentGrade == item.ID).ToListAsync(); comments.Add(commentVM); } var commentPageList = IQueryableExtensions.ToPaginatedList(comments.AsQueryable(), listPagePara.PageIndex, listPagePara.PageSize); var commentCollections = new List <CommentVM>(); foreach (var commentTermPage in commentPageList) { commentCollections.Add(commentTermPage); } var pageGroup = PagenateGroupRepository.GetItem(commentPageList, 5, listPagePara.PageIndex); ViewBag.PageGroup = pageGroup; ViewBag.PageParameter = listPagePara; return(View("~/Views/BusinessView/ActivityTermView/_GetComments.cshtml", commentCollections)); }
/// <summary> /// 获取用户活动列表 /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task <IActionResult> List(string id, string pageNumber) { if (pageNumber == "undefined") { pageNumber = "0"; } ////获取自己创建的 //var activityTermCollection = await _activityTermExtension.GetAll().Include(x => x.User).Include(x => x.User.Avatar).Where(x => x.Status == ActivityStatus.已结束 && x.User.Id == id && x.IsDisable).ToListAsync(); //获取自己参与的 var activityUserCollection = await _activityUserExtension.GetAll().OrderByDescending(x => x.ActivityTerm.StartDataTime).Include(x => x.ActivityTerm).Include(x => x.User).Include(x => x.User.Avatar) .Include(x => x.ActivityTerm.User).Include(x => x.ActivityTerm.User.Avatar).Where(x => x.ActivityTerm.Status == ActivityStatus.已结束 && x.User.Id == id && x.ActivityTerm.IsDisable).ToListAsync(); var activitys = new List <ActivityTerm>(); //activitys = activityUserCollection.Select(x => x.ActivityTerm).ToList(); //合并、去重 //var activitys = activityTermCollection.Union(activityUser).ToList(); activityUserCollection = activityUserCollection.Skip(Convert.ToInt32(pageNumber) * 10).Take(10).ToList(); if (activityUserCollection.Count == 0) { return(Json(false)); } var activityTermVM = new List <ActivityTermVM>(); foreach (var activity in activityUserCollection) { var acVM = new ActivityTermVM(activity.ActivityTerm); acVM.Images = await _businessImageExtension.GetAll().Where(x => x.RelevanceObjectID == activity.ActivityTerm.ID).ToListAsync(); acVM.Comments = await GetComments(activity.ActivityTerm.ID); //获取评论数量 acVM.CommentNumber = (await _commonExtension.GetAll().Include(x => x.Activity).Where(x => x.Activity.ID == activity.ActivityTerm.ID).ToListAsync()).Count; acVM.ActivityUser = activity.User; activityTermVM.Add(acVM); } return(View("~/Views/BusinessView/PersonalCenter/_List.cshtml", activityTermVM)); }
/// <summary> /// 根据ID查询对应的活动信息, /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task <IActionResult> Detail(Guid id) { var anAssociation = await _anAssociationRepository.GetSingleAsyn(id, x => x.User); var anVM = new AnAssociationVM(anAssociation); //获取图片 anVM.Images = await _businessImageRepository.GetAll().Where(x => x.RelevanceObjectID == id).ToListAsync(); //获取社团管理员的数量和用户的数量 var anUser = _anAssociationAndUserExtension.GetAll().OrderByDescending(x => x.AnJurisdictionManager).Include(x => x.User).Include(x => x.User.Avatar).Where(x => x.AnAssociationId == id); ViewBag.AnManagerNumber = (await anUser.Where(x => x.AnJurisdictionManager == AnJurisdiction.Founder || x.AnJurisdictionManager == AnJurisdiction.Admin).ToListAsync()).Count(); ViewBag.UserNumber = anUser.Count(); anVM.Members = anUser.ToList(); //获取社团活动 var activity = await _activityTermExtension.GetAll().Include(x => x.AnAssociation).Where(x => x.AnAssociation.ID == id).ToListAsync(); //anVM.Activitys = activity; ViewBag.ActivityNumber = activity.Count(); return(PartialView("~/Views/GroupOrganization/AnAssociation/_Detail.cshtml", anVM)); }
public async Task <IActionResult> Index() { var activityTremList = await _activityTermExtension.GetAll().OrderBy(x => x.CreateDateTime).Include(x => x.Avatar).Where(x => x.AnAssociation != null).ToListAsync(); activityTremList = activityTremList.Skip(0).Take(6).ToList(); var activityVMList = new List <ActivityTermVM>(); foreach (var item in activityTremList) { activityVMList.Add(new ActivityTermVM(item)); } var activityPerList = await _activityTermExtension.GetAll().OrderBy(x => x.CreateDateTime).Include(x => x.Avatar).Where(x => x.AnAssociation == null).ToListAsync(); activityPerList = activityPerList.Skip(0).Take(3).ToList();; var activityVMPerList = new List <ActivityTermVM>(); foreach (var item in activityPerList) { activityVMPerList.Add(new ActivityTermVM(item)); } var sowingMaps = await _homeExhibitionRepository.GetAll().OrderBy(x => x.CreateDateTime).Include(x => x.Avatar).Where(x => x.IsUse).ToListAsync(); sowingMaps = sowingMaps.Skip(0).Take(4).ToList(); //社团活动 ViewBag.activityVMList = activityVMList; //个人活动 ViewBag.activityVMPerList = activityVMPerList; //轮播图 var sowingMapList = new List <HomeExhibitionVM>(); foreach (var item in sowingMaps) { sowingMapList.Add(new HomeExhibitionVM(item)); } ViewBag.sowingMapList = sowingMapList; return(PartialView("~/Views/BusinessView/ShoolStart/Index.cshtml")); }
public async Task <IActionResult> Index() { var userCount = 9;//默认获取9个人 var users = await _userExtension.GetAll().Include(s => s.Avatar).ToListAsync(); userCount = userCount > users.Count ? users.Count : userCount; //判断是否够9个人 var ran = new Random(); var index = 0; var interests = new List <ApplicationUser>();//用于存储随机相同兴趣的人 for (int i = 0; i < userCount; i++) { index = ran.Next(0, users.Count()); interests.Add(users[index]); users.RemoveAt(index); } ViewBag.InterestUsers = interests; return(View("~/Views/BusinessView/ActivityTermView/Index.cshtml")); }
/// <summary> /// 更改所有活动的状态 /// </summary> /// <param name="source"></param> /// <param name="e"></param> public void EditActivityStatus(object source, ElapsedEventArgs e) { var activityList = _activityTermExtension.GetAll().Where(x => (x.Status == ActivityStatus.未开始 || x.Status == ActivityStatus.进行中) && x.StartDataTime > DateTime.Now).ToList(); foreach (var activity in activityList) { if (activity.StartDataTime > DateTime.Now && activity.EndDataTime > DateTime.Now) { activity.Status = ActivityStatus.进行中; _activityTermExtension.Edit(activity); } else if (activity.EndDataTime < DateTime.Now) { activity.Status = ActivityStatus.已结束; _activityTermExtension.Edit(activity); } _activityTermExtension.Save(); } }
public async Task <IActionResult> SingAndExchange(int index) { var datas = await _anassociationExtension.GetAll().Include(x => x.Avatar).ToListAsync(); datas = datas.Skip(index * pageSize).Take(pageSize).ToList(); var flag = false; var anAssociations = new List <AnAssociationVM>(); if (datas.Count() == 0) { datas = (await _anassociationExtension.GetAllAsyn()).Take(pageSize).ToList(); flag = true; } foreach (var item in datas) { var anVm = new AnAssociationVM(item) { AnAssociationNum = (await _anassociationAndUserExtension.GetAll().Where(x => x.AnAssociationId == item.ID).ToListAsync()).Count }; anAssociations.Add(anVm); } return(Json(new { Items = anAssociations, ifLastIndex = flag })); }
/// <summary> /// 添加进首页呈现 /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task <IActionResult> HomeExhibitionPresent(Guid id) { var homeExhhibition = await _homeExhibitionExtension.GetAll().Include(x => x.Activity).Where(x => x.Activity.ID == id).FirstOrDefaultAsync(); if (homeExhhibition != null) { return(Json(new { isOK = false, message = homeExhhibition.Activity.Name + "已在首页显示设置里,请在首页显示设置模块设置允许显示" })); } var activity = await _activityTermExtension.GetAll().Include(x => x.Avatar).Where(x => x.ID == id).FirstOrDefaultAsync(); homeExhhibition = new HomeExhibition() { Name = activity.Name, Activity = activity, Description = activity.Description, CreateDateTime = DateTime.Now, StartDateTime = DateTime.Now, EndDateTime = activity.EndDataTime, Avatar = activity.Avatar, ExhibitionLeve = ExhibitionLevelEnum.Highest }; _homeExhibitionExtension.AddAndSave(homeExhhibition); return(Json(new { isOK = true, message = activity.Name + "添加进首页显示成功,请在首页显示设置模块设置允许显示" })); }
public async Task <IActionResult> List(string keywork, string listPageParaJson) { var listPagePara = new ListPageParameter(); if (listPageParaJson != null && listPageParaJson != "") { listPagePara = Newtonsoft.Json.JsonConvert.DeserializeObject <ListPageParameter>(listPageParaJson); } var heVMCollection = new List <HomeExhibitionVM>(); var homeExhibitionCollection = new List <HomeExhibition>(); if (!String.IsNullOrEmpty(keywork)) { Expression <Func <HomeExhibition, bool> > condtion = x => x.Name.Contains(keywork) || x.Activity.Name.Contains(keywork) || x.Activity.User.Name.Contains(keywork); homeExhibitionCollection = await _homeExhibitionRepository.GetAll().Include(x => x.Activity).Include(x => x.Activity.User). Include(x => x.Avatar).Where(condtion).OrderBy(x => x.CreateDateTime).ToListAsync(); } else { homeExhibitionCollection = await _homeExhibitionRepository.GetAll().Include(x => x.Activity).Include(x => x.Activity.User). Include(x => x.Avatar).OrderBy(x => x.CreateDateTime).ToListAsync(); } var homeExhibitionPageList = IQueryableExtensions.ToPaginatedList(homeExhibitionCollection.AsQueryable(), listPagePara.PageIndex, listPagePara.PageSize); foreach (var item in homeExhibitionPageList) { heVMCollection.Add(new HomeExhibitionVM(item)); } var pageGroup = PagenateGroupRepository.GetItem(homeExhibitionPageList, 5, listPagePara.PageIndex); ViewBag.PageGroup = pageGroup; ViewBag.PageParameter = listPagePara; return(View("~/Views/GroupOrganization/HomeExhibition/_List.cshtml", heVMCollection)); }
/// <summary> /// 普通读者用户资料注册管理 /// </summary> /// <param name="jsonRegisetrInformation"></param> /// <returns></returns> public async Task <IActionResult> Register(string jsonRegisterInformation) { var validateMessage = new ValidateMessage(); var loUser = Newtonsoft.Json.JsonConvert.DeserializeObject <LogonInformation>(jsonRegisterInformation);//获取前端数据放到用户视图模型里边 if (loUser.ConfirmPassword != loUser.Password) { validateMessage.IsOK = false; validateMessage.ValidateMessageItems.Add( new ValidateMessageItem { IsPropertyName = false, MessageName = "Succeed", Message = "密码和确认密码不一致", }); return(Json(validateMessage)); } if (ModelState.IsValid) { var isNewUser = await _userManager.FindByNameAsync(loUser.UserName); if (isNewUser != null) { validateMessage.IsOK = false; validateMessage.ValidateMessageItems.Add( new ValidateMessageItem { IsPropertyName = false, MessageName = "Succeed", Message = "登录名重复", }); return(Json(validateMessage)); } var user = new ApplicationUser() { Name = loUser.UserName, UserName = loUser.UserName, TwoFactorEnabled = true, Email = loUser.Email, NormalizedUserName = loUser.UserName, SecurityStamp = Guid.NewGuid().ToString(), Avatar = await _businessImageExtension.GetAll().Where(x => x.Name == "头像" && x.IsSystem).FirstOrDefaultAsync(), RegisterTime = DateTime.Now, Power = AnJurisdiction.Ordinary, }; _userExtension.Add(user); user.PasswordHash = new PasswordHasher <ApplicationUser>(new OptionsWrapper <PasswordHasherOptions>(new PasswordHasherOptions())).HashPassword(user, loUser.Password); await _userExtension.SaveAsyn(); validateMessage.IsOK = true; validateMessage.ValidateMessageItems.Add( new ValidateMessageItem { IsPropertyName = false, MessageName = "Succeed", Message = "注册成功,请登录" }); return(Json(validateMessage)); } else { validateMessage.IsOK = false; var errCollection = from errKey in ModelState.Keys from errMessage in ModelState[errKey].Errors where ModelState[errKey].Errors.Count > 0 select(new { errKey, errMessage.ErrorMessage }); foreach (var errItem in errCollection) { var vmItem = new ValidateMessageItem() { IsPropertyName = true, MessageName = errItem.errKey, Message = errItem.ErrorMessage }; validateMessage.ValidateMessageItems.Add(vmItem); } return(Json(validateMessage)); } }
/// <summary> /// 管理中心初始界面 /// </summary> /// <returns></returns> public async Task <IActionResult> Index(string id) { var user = User.Claims.FirstOrDefault(); //判断用户是否登录 if (user == null) { return(RedirectToAction("NotLogin", "Home")); } if (id == null) { id = user.Value; } var userInfo = await _userExtension.GetAll().Include(x => x.Avatar).Where(x => x.Id == id).FirstOrDefaultAsync(); if (userInfo == null) { return(RedirectToAction("NotLogin", "Home")); } var userVM = new ApplicationUserVM(userInfo); var hobbys = await _userHoppyExtension.GetAll().Include(x => x.Hobby).Include(x => x.User).Where(x => x.User.Id == id).ToListAsync(); userVM.Hobbys = new List <Hobby>(); foreach (var item in hobbys) { userVM.Hobbys.Add(item.Hobby); } var userCount = 9;//默认获取9个人 var users = await _userExtension.GetAll().Include(s => s.Avatar).ToListAsync(); userCount = userCount > users.Count ? users.Count : userCount; //判断是否够9个人 var ran = new Random(); var index = 0; var interests = new List <ApplicationUser>();//用于存储随机相同兴趣的人 for (int i = 0; i < userCount; i++) { index = ran.Next(0, users.Count()); interests.Add(users[index]); users.RemoveAt(index); } ViewBag.InterestUsers = interests; //获取用户好友数量 var userFriens = await _userFriendExtension.GetAll().Where(x => x.UserID == id).ToListAsync(); ViewBag.Friends = userFriens.Count; //获取社团数量 var anAssociations = await _anAssociationExtension.GetAll().Include(x => x.User).Where(x => x.User.Id == id).ToListAsync(); var userAnAssociations = await _userAnAssociationExtension.GetAll().Include(x => x.User).Where(x => x.User.Id == id).ToListAsync(); ViewBag.AnAssociations = anAssociations.Count + userAnAssociations.Count; //获取活动数量 //var activitys = await _activityTermExtension.GetAll().Include(x => x.User).Where(x => x.User.Id == id && x.Status == ActivityStatus.已结束).ToListAsync(); var userActivitys = await _activityUserExtension.GetAll().Include(x => x.User).Where(x => x.User.Id == id && x.ActivityTerm.Status == ActivityStatus.已结束).ToListAsync(); ViewBag.Activitys = userActivitys.Count; return(View("~/Views/BusinessView/PersonalCenter/Index.cshtml", userVM)); }