public async Task <IHttpActionResult> FindAllBookings(string bookingNumber = null, int?activityId = null, int pageIndex = 1, int pageSize = 10, string include = null, string orderBy = "CreateDate DESC", int?supplierId = null, string bookingUserName = null, string bookingUserEmail = null, SharedEnums.BookingConfirmationStatus bookingStatusId = SharedEnums.BookingConfirmationStatus.All) { try { Pager pager = new Pager() { PageSize = pageSize, PageIndex = pageIndex }; Expression <Func <Booking, bool> > Filter = x => !x.IsDeleted; if (!string.IsNullOrWhiteSpace(bookingNumber)) { bookingNumber = bookingNumber.ToLower().Trim(); Filter = Filter.And(x => x.BookingNumber.ToLower().Trim().Contains(bookingNumber)); } if (activityId.HasValue) { Filter = Filter.And(x => x.ActivityId == activityId.Value); } if (supplierId.HasValue) { Filter = Filter.And(x => x.Activity.SupplierId == supplierId.Value); } if (!string.IsNullOrEmpty(bookingUserName)) { bookingUserName = bookingUserName.ToLower(); Filter = Filter.And(x => !x.IsDeleted && ((x.User.FirstName + " " + x.User.LastName).ToLower().Contains(bookingUserName))); } if (!string.IsNullOrEmpty(bookingUserEmail)) { bookingUserEmail = bookingUserEmail.ToLower(); Filter = Filter.And(x => x.User.Email.ToLower().Contains(bookingUserEmail)); } if (bookingStatusId != SharedEnums.BookingConfirmationStatus.All) { Filter = Filter.And(x => x.Status == bookingStatusId); } var bookings = await Mgr.FindAll_Async(Filter, orderBy, pager, Helper.ToStringArray(include)); HttpContext.Current.Response.Headers.Add("access-control-expose-headers", "X-Pager"); HttpContext.Current.Response.Headers.Add("X-Pager", Newtonsoft.Json.JsonConvert.SerializeObject(pager)); return(Ok(bookings)); } catch (Exception ex) { Unit.LogError(ex, this.ToString(), this.ActionContext.ActionArguments.ToList()); return(InternalServerError(ex)); } }