예제 #1
0
        public ActionResult Index(SearchResultsViewModel model)
        {
            if (!string.IsNullOrWhiteSpace(model.Keyword))
            {
                if (!string.IsNullOrEmpty(model.TimeZoneId))
                {
                    new SearchHandler(Services).SetClientTimeZone(model.TimeZoneId);
                }

                var currentUserId = GetCurrentUserId();
                var lstSpecialist = Services.Search.StandardSearchByAmazon(model.Keyword, 0, -1, model.SortBy, currentUserId);
                if (lstSpecialist != null && lstSpecialist.Count > 0)
                {
                    model.ListResult = AutoMapper.Mapper.Map<List<SearchResultDto>, List<SearchResultViewModel>>(lstSpecialist);
                    model.Total = model.ListResult.Count;
                    foreach (var result in model.ListResult)
                    {
                        int number = result.StandardHour.Specializations.Count;
                        for (int i = 0; i < number; i++)
                        {
                            result.StandardHour.Specializations[i].CustomerPricing = Services.Booking.GetCustomerPricing(result.StandardHour.Specializations[i].Id);
                        }
                        if (currentUserId != null)
                        {
                            result.IsFavourite = Services.Users.IsFavourite(result.StandardHour.SpecialistId, currentUserId);
                        }
                        result.User.AvatarPath = S3ReaderHelper.CombineS3Root(result.User.AvatarPath);
                        result.RatingRatio = (int)Math.Round(Services.Booking.RatingCalculator(result.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(result.User.CurrentAvailabilityStatus))
                        {
                            //check specialist is calling with customer to change currentt status to "not avaiable"
                            if (Services.Call.CheckCallInProgressBySpecialistId(result.User.Id))
                            {
                                result.User.CurrentAvailabilityStatus = AvailabilityStatus.NotAvailable;
                            }
                        }
                    }
                }
            }

            return View(model);
        }
예제 #2
0
        /// <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;
        }