public async Task <IActionResult> Category(string categoryName) { ViewData["Title"] = categoryName; var category = await new BLL.Category(unitOfWork).Get(new EF.Category { Name = categoryName }); if (category == null) { return(StatusCode(404)); } else if (category.DateInactive != null) { return(StatusCode(403)); } var blogs = (await new BLL.Blog(unitOfWork).FindByCategoryId(category.CategoryId)).Where(x => x.DateInactive == null); var page = Convert.ToInt16(Request.Query["page"]); var pager = new Core.Pager(blogs.Count(), page == 0 ? 1 : page); blogs = blogs.Skip((pager.CurrentPage - 1) * pager.PageSize).Take(pager.PageSize); return(View(new Tuple <EF.Category, Core.Pager, List <EF.Blog> >(category, pager, blogs.ToList()))); }
public async Task <IActionResult> PageAttendees(int id, int p) { var bll_a = attendanceBusiness; var res = from r in bll_a.Find(new EF.Attendance { EventId = id }).OrderBy(x => x.Member.Name) select new { r.Member.Name, r.MemberId, r.DateTimeLogged }; var page = p; var pager = new Core.Pager(await res.CountAsync(), page == 0 ? 1 : page, 100); dynamic obj1 = new ExpandoObject(); obj1.attendees = await res.Skip((pager.CurrentPage - 1) *pager.PageSize).Take(pager.PageSize).ToListAsync(); obj1.pager = pager; return(Json(obj1)); }
public async Task <IActionResult> Page([FromBody] EF.Event obj, int id) { var bll_event = eventBusiness; var user = HttpContext.Items["EndUser"] as EF.EndUser; obj.EventCategory = new EF.EventCategory { CommunityId = user.Member.CommunityId }; var res = from r in bll_event.Find(obj) select new { r.Id, r.EventCategoryId, Category = r.EventCategory.Name, r.Name, r.IsActive, r.DateTimeStart, Location = (r.Location == null ? "" : r.Location.Name), Attendance = r.Attendance.Count, r.IsExclusive }; var page = id; var pager = new Core.Pager(await res.CountAsync(), page == 0 ? 1 : page, 100); dynamic obj1 = new ExpandoObject(); obj1.events = await res.Skip((pager.CurrentPage - 1) *pager.PageSize).Take(pager.PageSize).ToListAsync(); obj1.pager = pager; return(Json(obj1)); }
public async Task <IActionResult> Page([FromBody] Models.Member obj, int id) { try { var bll_member = memberBusiness; var user = HttpContext.Items["EndUser"] as EF.EndUser; obj.CommunityId = user.Member.CommunityId.Value; var o = this.mapper.Map <EF.Member>(obj); if (obj.RoleId != null) { o.EndUser = new EF.EndUser { RoleId = obj.RoleId.Value } } ; var members = bll_member.Find(o).Where(x => x.IsActive == (obj.IsActive ?? x.IsActive)); var page = id; var pager = new Core.Pager(await members.CountAsync(), page == 0 ? 1 : page, 100); var res = from r in await members.Skip((pager.CurrentPage - 1) *pager.PageSize).Take(pager.PageSize).ToListAsync() join m in bll_member.Find(new EF.Member { CommunityId = obj.CommunityId }) on r.InvitedBy equals m.Id into g from m1 in g.DefaultIfEmpty() select new { r.Id, r.Name, r.NickName, r.Address, r.Mobile, r.Email, r.BirthDate, r.Remarks, r.CivilStatus, r.Gender, InvitedByMemberName = m1 == null ? "" : m1.Name, r.IsActive, RoleId = r.EndUser == null ? 0 : r.EndUser.RoleId }; dynamic obj1 = new ExpandoObject(); obj1.members = res; obj1.pager = pager; return(Json(obj1)); } catch (Exception ex) { logger.Error(ex); return(BadRequest()); } }
public async Task <IActionResult> Page([FromBody] Models.Group obj, int id) { var bll_g = groupBusiness; var user = HttpContext.Items["EndUser"] as EF.EndUser; var o = this.mapper.Map <EF.Group>(obj); o.GroupCategory = new EF.GroupCategory { CommunityId = user.Member.CommunityId }; // Get group leader id var bll_m = memberBusiness; var glid = await bll_m.GetIdByName(obj.Leader ?? "", user.Member.CommunityId.Value); o.GroupLeader = glid; var res = from r in bll_g.Find(o) join m in bll_m.Find(new EF.Member { CommunityId = user.Member.CommunityId }) on r.GroupLeader equals m.Id select new { r.Id, r.GroupCategoryId, Category = r.GroupCategory.Name, r.Name, Members = r.GroupMember.Count, Leader = m.Name, LeaderMemberId = m.Id, isMember = r.GroupMember.Count(x => x.MemberId == user.MemberId) > 0, isLeader = user.MemberId == m.Id }; var page = id; var pager = new Core.Pager(await res.CountAsync(), page == 0 ? 1 : page, 100); dynamic obj1 = new ExpandoObject(); obj1.groups = await res.Skip((pager.CurrentPage - 1) *pager.PageSize).Take(pager.PageSize).ToListAsync(); obj1.pager = pager; return(Json(obj1)); }
// GET: /<controller>/ public async Task <IActionResult> Index() { var qry = Request.Query["qry"].ToString(); var res = await new BLL.Blog(unitOfWork).Find(new EF.Blog { Title = qry, Body = qry }); res = res.Where(x => x.DateInactive == null); int cnt = res.Count(); var page = Convert.ToInt16(Request.Query["page"]); var pager = new Core.Pager(res.Count(), page == 0 ? 1 : page); res = res.Skip((pager.CurrentPage - 1) * pager.PageSize).Take(pager.PageSize); ViewBag.SearchResult = res.ToList(); return(View(new Tuple <Models.Search, Core.Pager, int>(new Models.Search { Query = qry ?? "" }, pager, cnt))); }
public async Task <IActionResult> Category(string categoryName) { var category = await new BLL.Category(unitOfWork).Get(new EF.Category { Name = categoryName }); if (category == null) { return(StatusCode(404)); } else if (category.DateInactive != null) { return(StatusCode(403)); } var res = from r in (await new BLL.Blog(unitOfWork).FindByCategoryId(category.CategoryId)).Where(x => x.DateInactive == null) select new { r.BlogId, r.Title, Body = Regex.Replace(r.Body, "<.*?>", String.Empty), r.DatePublished, r.CreatedBy, r.DateCreated, r.ModifiedBy, r.DateModified, PhotoUrl = r.BlogPhoto.FirstOrDefault() == null ? "" : $"{this.Request.Scheme}://{this.Request.Host}{this.Request.PathBase}/" + r.BlogPhoto.First().Photo.Url }; var page = Convert.ToInt16(Request.Query["page"]); var pager = new Core.Pager(res.Count(), page == 0 ? 1 : page); return(Json(new { category = new { category.CategoryId, category.Name }, blogs = res.Skip((pager.CurrentPage - 1) * pager.PageSize).Take(pager.PageSize).ToList(), pager = pager })); }
public async Task <IActionResult> Page([FromBody] string member, int id, int p) { var bll_a = attendanceBusiness; var res = from r in (await bll_a.Registrants(id, member)) select new { r.Member.Name, r.MemberId, r.DateTimeLogged }; var page = p; var pager = new Core.Pager(await res.CountAsync(), page == 0 ? 1 : page, 100); dynamic obj1 = new ExpandoObject(); obj1.registrants = await res.Skip((pager.CurrentPage - 1) *pager.PageSize).Take(pager.PageSize).ToListAsync(); obj1.pager = pager; return(Json(obj1)); }
public async Task <IActionResult> Page([FromBody] string member, int id, int p) { var bll_g = groupBusiness; var bll_gm = groupMemberBusiness; var user = HttpContext.Items["EndUser"] as EF.EndUser; if (!await bll_g.IsSelectedIdsOk(new int[] { id }, user)) { return(Unauthorized()); } var m = new EF.Member { Name = member, CommunityId = user.Member.CommunityId }; var res = from r in bll_gm.Checklist(m, id) select new { r.Member.Name, r.MemberId, r.GroupId }; var page = p; var pager = new Core.Pager(await res.CountAsync(), page == 0 ? 1 : page, 100); dynamic obj1 = new ExpandoObject(); obj1.checklist = await res.Skip((pager.CurrentPage - 1) *pager.PageSize).Take(pager.PageSize).ToListAsync(); obj1.pager = pager; return(Json(obj1)); }