private IQueryable <P> SearchP(P1PHomeVM p1, int count, IQueryable <P> p1s) { if (p1.Name != null && count == 1) { p1s = p1s.Where(p => p.Name == p1.Name); return(SearchP(p1, 2, p1s)); } else if (p1.NameAct != null && (count == 1 || count == 2)) { p1s = p1s.Where(p => p.Operation.NameAct == p1.NameAct); return(SearchP(p1, 3, p1s)); } else if (p1.StData != null && p1.FinData != null && (count == 1 || count == 2 || count == 3)) { p1s = p1s.Where(p => p.Data >= p1.StData && p.Data <= p1.FinData); return(SearchP(p1, 4, p1s)); } else if (p1.minsum != 0 && p1.maxsum != 0 && (count == 1 || count == 2 || count == 3 || count == 4)) { p1s = p1s.Where(p => p.Sum >= p1.minsum && p.Sum <= p1.maxsum); return(SearchP(p1, 5, p1s)); } else { return(p1s); } }
public IActionResult P1PHome(P1PHomeVM p1P, int?idoper) { IQueryable <P> p = db.Ps.Include(c => c.Operation).ThenInclude(u => u.Plan).ThenInclude(u => u.User); p = p.Where(p => p.Operation.Plan.User.Email == User.Identity.Name); if (idoper != null) { p = p.Where(p => p.OperationId == idoper); IQueryable <Operation> ops = db.Operations.Include(c => c.Plan); ops = ops.Where(p => p.Id == idoper); foreach (Operation p1 in ops) { p1P.Data = p1.Plan.Data; p1P.DataPeriod = p1.Plan.DataPeriod; break; } p1P.Ps = SearchP(p1P, 1, p); p1P.idoper = idoper; return(View(p1P)); } else { IQueryable <P1> p1 = db.P1s.Include(c => c.User); p1 = p1.Where(p => p.User.Email == User.Identity.Name); p1P.Ps = SearchP(p1P, 1, p); p1P.P1s = SearchP1(p1P, 1, p1); return(View(p1P)); } }