public IEnumerable <ComputerLabForList> SearchComputerLabsForBooking(LabParams labParams) { var labs = _context.ComputerLabs.Include(l => l.Bookings) // .Where(l => CheckValidComputerLab(l.Bookings, labParams.BookingDate, labParams.StartAt, labParams.EndAt)); .Where(l => !l.Bookings.Any(b => b.BookingDate.Date == labParams.BookingDate.Date && ((b.EndAt >= labParams.StartAt && b.StartAt <= labParams.EndAt) || (b.StartAt >= labParams.StartAt && b.StartAt <= labParams.EndAt)))); return(_mapper.Map <IEnumerable <ComputerLabForList> >(labs)); }
public IEnumerable <ComputerLabForList> GetComputerLabs([FromQuery] LabParams labParams) { labParams.OwnerId = Convert.ToInt32(User.FindFirst(ClaimTypes.NameIdentifier).Value); var labs = _service.GetComputerLabs(labParams); Response.AddPagination(labs.CurrentPage, labs.PageSize, labs.TotalCount, labs.TotalPages); return(_mapper.Map <IEnumerable <ComputerLabForList> >(labs)); }
// for LECTURER public IEnumerable <ComputerLabForList> SearchComputerLabsForBooking([FromQuery] LabParams labParams) { var labs = _service.SearchComputerLabsForBooking(labParams); // Response.AddPagination(labs.CurrentPage, labs.PageSize, labs.TotalCount, labs.TotalPages); foreach (var lab in labs) { lab.EditMode = labParams.EditMode; } return(labs); }
public PagedList <ComputerLab> GetComputerLabs(LabParams labParams) { IQueryable <ComputerLab> labs; if (labParams.OwnerId == 8) { labs = _context.ComputerLabs; } else { labs = _context.ComputerLabs.Where(l => l.OwnerId == labParams.OwnerId).AsQueryable(); } return(PagedList <ComputerLab> .Create(labs, labParams.PageNumber, labParams.PageSize)); }