public ActionResult AdvancedSearch(AdvancedSearchViewModel model) { try { SearchHandler searchHandler = new SearchHandler(Services); if (!string.IsNullOrEmpty(model.TimeZoneId)) { searchHandler.SetClientTimeZone(model.TimeZoneId); } return View("Index", searchHandler.AdvancedSearch(GetCurrentUserId(), model, 0, -1)); } catch (Exception e) { Log.Error("Search and mapping domain to view model", e); return View("Error"); } }
/// <summary> /// Used for advance search on web and API for mobile /// </summary> /// <param name="userId">user Id</param> /// <param name="model">AdvancedSearchViewModel</param> /// <returns>SearchResultsViewModel</returns> public SearchResultsViewModel AdvancedSearch( Guid userId, AdvancedSearchViewModel model, int start, int size) { var result = new SearchResultsViewModel { SortBy = model.SortBy }; var lstSpecialist = Services.Search.AdvancedSearchByAmazon( Mapper.Map<AdvancedSearchDto>(model), start, size, model.SortBy, userId); if (lstSpecialist != null) { result.ListResult = AutoMapper.Mapper.Map<List<SearchResultDto>, List<SearchResultViewModel>>(lstSpecialist); result.Total = result.ListResult.Count; //assign calculated rate to each specialization foreach (var item in result.ListResult) { int number = item.StandardHour.Specializations.Count; for (int i = 0; i < number; i++) { item.StandardHour.Specializations[i].CustomerPricing = Services.Booking.GetCustomerPricing(item.StandardHour.Specializations[i].Id); } item.User.AvatarPath = S3ReaderHelper.CombineS3Root(item.User.AvatarPath); item.RatingRatio = (int)Math.Round(Services.Booking.RatingCalculator(item.User.Id), 0, MidpointRounding.AwayFromZero); //check current status is not "Not Available". if It is yes, it access db to check call if (!AvailabilityStatus.NotAvailable.Equals(item.User.CurrentAvailabilityStatus) && Services.Call.CheckCallInProgressBySpecialistId(item.User.Id)) { item.User.CurrentAvailabilityStatus = AvailabilityStatus.NotAvailable; } } return result; } return null; }