public IHttpActionResult GetFavourites(SearchApi location) { Mapper.CreateMap<FavouriteDto, FavouriteViewModel>(); Mapper.CreateMap<UserDto, UserApi>(); try { if (CurrentUser.Role == Role.Customer) { var favouites = Services.Users.GetFavouriteListByCustomerId(CurrentUser.Id); var result = new List<SpecialistProfileViewModel>(); SpecialistProfileViewModel model = new SpecialistProfileViewModel(); foreach (var f in favouites) { model = SpecialistDetailModelMapper.ModelMapper(f.Specialist, CurrentUser.Id, Services); //Calculate proximity between customer and specialist from lat-long or from IP of user. TeleConsult.Infrastructure.Core.External.Coordinates searcherLocation = null; if (location != null && (location.Latitude > 0 || location.Longitude > 0)) { searcherLocation = new TeleConsult.Infrastructure.Core.External.Coordinates(); searcherLocation.Latitude = location.Latitude; searcherLocation.Longitude = location.Longitude; } else //-- Calculate lat-long from user's IP address { searcherLocation = Services.Search.GetPositionSearcher(CurrentUser.Id); } model.Proximity = Services.Search.GetDistance(searcherLocation, f.Specialist); if (model.Proximity == 999999) { model.Proximity = null; } result.Add(model); } return Json(result); } return Json(new { Status = false }); } catch (Exception e) { Log.Error("Check is favourite or not", e); return Json(new { Status = false, Message = e.Message }); } }
public List<SpecialistProfileViewModel> StandardSearch(SearchApi searchModel) { var result = new List<SpecialistProfileViewModel>(); try { if (!string.IsNullOrEmpty(searchModel.TimeZoneId)) { new SearchHandler(Services).SetClientTimeZone(searchModel.TimeZoneId); } //Prepare Data Guid currentUserId = CurrentUser != null ? CurrentUser.Id : Guid.Empty; var sortBy = (SortBy)Enum.Parse(typeof(SortBy), searchModel.TypeSort); TeleConsult.Infrastructure.Core.External.Coordinates searcherLocation = null; if (searchModel.Latitude > 0 || searchModel.Longitude > 0) { searcherLocation = new TeleConsult.Infrastructure.Core.External.Coordinates(); searcherLocation.Latitude = searchModel.Latitude; searcherLocation.Longitude = searchModel.Longitude; } //Get data from Amazon var userList = Services.Search.StandardSearchByAmazon( searchModel.KeySearch, searchModel.Start, searchModel.Size, sortBy, currentUserId, searcherLocation); return HandleDataFromAmazon(userList); } catch (System.Exception e) { Log.Error("Standard search API. Error: " + e.Message + " StracKTrace: " + e.StackTrace); throw new HttpResponseException(HttpStatusCode.InternalServerError); } }