public async Task <PaymentlogPagedVM> MyProjectPaymentlogsAsync(int page, int pageSize, int projectId) { var strUserId = "13d818fd-687c-c44c-8413-08d522565bcc"; //_httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.Sid).Value; var userId = new Guid(strUserId); var vm = new PaymentlogPagedVM { PageIndex = page - 1, PageSize = pageSize, ProjectId = projectId }; var query = _context.Paymentlogs.Include(d => d.Project) .Where(d => d.Project.UserProjects.Any(c => c.UserId == userId)).AsQueryable(); if (projectId > 0) { query = query.Where(d => d.ProjectId == projectId); } vm.RowCount = await query.CountAsync(); vm.Paymentlogs = await query.OrderByDescending(d => d.Id).Skip(vm.PageIndex * vm.PageSize) .Take(vm.PageSize) .ProjectTo <PaymentlogVM>(_mapper.ConfigurationProvider).ToListAsync(); return(vm); }
public async Task <PaymentlogPagedVM> GetMyPaymentlogsAsync(int projectId) { var vm = new PaymentlogPagedVM { ProjectId = projectId }; var strUserId = _httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.Sid).Value; var userId = new Guid(strUserId); var query = _context.Paymentlogs.Where(d => d.Project.UserProjects.Any(p => p.UserId == userId) || d.Project.Manager == userId).Include(d => d.Project).AsQueryable(); if (projectId > 0) { query = query.Where(d => d.ProjectId == projectId); } vm.RowCount = await query.CountAsync(); vm.Paymentlogs = await query.OrderByDescending(d => d.Id).ProjectTo <PaymentlogVM>(_mapper.ConfigurationProvider).ToListAsync(); return(vm); }
public async Task <PaymentlogPagedVM> GetPaymentlogsAsync(int page, int pageSize, int projectId) { var vm = new PaymentlogPagedVM { PageIndex = page - 1, PageSize = pageSize, ProjectId = projectId }; var query = _context.Paymentlogs.Include(d => d.Project).AsQueryable(); if (projectId > 0) { query = query.Where(d => d.ProjectId == projectId); } vm.RowCount = await query.CountAsync(); vm.Paymentlogs = await query.OrderByDescending(d => d.Id).Skip(vm.PageIndex * vm.PageSize) .Take(vm.PageSize) .ProjectTo <PaymentlogVM>(_mapper.ConfigurationProvider).ToListAsync(); return(vm); }
public async Task <PaymentlogPagedVM> GetListAsync(int page, int pageSize, int?projectId, string orderBy, string orderMode) { var vm = new PaymentlogPagedVM { PageIndex = page - 1, PageSize = pageSize, ProjectId = projectId ?? 0, OrderBy = orderBy, OrderMode = orderMode, }; var query = _db.Paymentlogs.Include(d => d.Project).AsQueryable(); if (projectId > 0) { query = query.Where(d => d.ProjectId == projectId); } vm.RowCount = await query.CountAsync(); if (!string.IsNullOrEmpty(orderBy)) { switch (orderBy) { case "money": if (orderMode == "desc") { query = query.OrderByDescending(d => d.Money); } else { query = query.OrderBy(d => d.Money); } break; case "createdDate": if (orderMode == "desc") { query = query.OrderByDescending(d => d.CreatedDate); } else { query = query.OrderBy(d => d.CreatedDate); } break; default: query = query.OrderByDescending(d => d.CreatedDate); break; } } else { query = query.OrderByDescending(d => d.CreatedDate); } vm.Paymentlogs = await query.Skip(vm.PageIndex *vm.PageSize) .Take(vm.PageSize) .ProjectTo <PaymentlogVM>(_mapper.ConfigurationProvider).ToListAsync(); return(vm); }