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 SpecialistProfileViewModel SpecialistProfile(UsersIdentification usersId) { SpecialistProfileViewModel model = new SpecialistProfileViewModel(); var account = Services.Users.GetUserById(usersId.SpecialistId); model = SpecialistDetailModelMapper.ModelMapper(account, CurrentUser.Id, Services); string timeZoneId = CurrentUser != null ? CurrentUser.DefaultTimeZoneId : TimeZoneInfo.Local.Id; model.SpecialistDetail.ListStandardHour = TeleConsult.Web.Code.Helpers.DateTimeHelper.TimeZoneForWorkingSchedule( timeZoneId, model.SpecialistDetail.ListStandardHour, Utilities.GetTimeZoneIdByName(account.Locations[0].TimeZone)); for (int i = 0; i < model.SpecialistDetail.Specializations.Count; i++) { model.SpecialistDetail.Specializations[i].CustomerPricing = Services.Booking.GetCustomerPricing(model.SpecialistDetail.Specializations[i].Id); } return model; }
/// <summary> /// Mapping from Specialist profile, country permitted, standard hour and user informatiom to SpecialistProfileViewModel /// </summary> /// <param name="specialization"></param> /// <param name="specProfile"></param> /// <param name="standardHour"></param> /// <returns></returns> public static SpecialistProfileViewModel ModelMapper( UserDto account, Guid? currentUserId, IServices Services) { SpecialistProfileViewModel model = new SpecialistProfileViewModel(); model.Account = Mapper.Map<UserDto, UserViewModel>(account); SpecialistRegisterStep3ViewModel step3Model = new SpecialistRegisterStep3ViewModel(); step3Model = Mapper.Map<ProfileDto, SpecialistRegisterStep3ViewModel>(account.Profile); step3Model.ListStandardHour = Mapper.Map<List<WorkingScheduleDto>, List<WorkingScheduleDto>>(account.Profile.WorkingSchedules.ToList()); step3Model.Specializations = Mapper.Map<List<SpecializationDto>, List<SpecializationViewModel>>(account.Profile.Specializations.ToList()); List<PermittedCountryViewModel> lstCountryPermitted = new List<PermittedCountryViewModel>(); List<StateAndRegulatory> lstStateAndRegulatory = new List<StateAndRegulatory>(); foreach (var spec in step3Model.Specializations) { foreach (var country in spec.PermittedCountries) { var tempState = country.State.Split('_').ToList(); var tempRegulatory = country.RegulatoryAuthority.Split('_').ToList(); lstStateAndRegulatory = new List<StateAndRegulatory>(); for (int i = 0; i < tempState.Count(); i++) { if (!string.IsNullOrEmpty(tempState[i]) && !string.IsNullOrEmpty(tempRegulatory[i])) { lstStateAndRegulatory.Add( new StateAndRegulatory { State = tempState[i], Regulatory = tempRegulatory[i] }); } } lstCountryPermitted.Add(new PermittedCountryViewModel { Name = country.Name, StatesAndRegulatories = lstStateAndRegulatory }); } spec.lstCountryPermitted = lstCountryPermitted; spec.CustomerPricing = Services.Booking.GetCustomerPricing(spec.Id); // Format S3 link for (int i = 0; i < spec.POCs.Count; i++) { spec.POCs[i].S3FileName = TeleConsult.Web.Code.Helpers.S3ReaderHelper.CombineFileS3Root(spec.POCs[i].S3FileName); } } if (string.IsNullOrEmpty(model.Account.AvatarPath)) { model.Account.AvatarPath = ConstPath.DefaulAvatar; } else { var s3Root = BlueChilli.Web.Helpers.S3PathWithoutQuery("").Substring(1); model.Account.AvatarPath = Path.Combine(s3Root, account.Avatar); } model.SpecialistDetail = step3Model; model.IsFavourite = Services.Users.IsFavourite(model.Account.Id, currentUserId); model.SpecialistDetail.RatingRatio = (int)Math.Round(Services.Booking.RatingCalculator(account.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(model.Account.CurrentAvailabilityStatus) && Services.Call.CheckCallInProgressBySpecialistId(model.Account.Id)) { model.Account.CurrentAvailabilityStatus = AvailabilityStatus.NotAvailable; } return model; }
public ActionResult LoadPopupTalkNow(Guid specialistId) { ViewBag.PaymentMethod = CurrentUser.PaymentMethod != 0 ? Enums.GetDescriptionEnum(CurrentUser.PaymentMethod) : Enums.GetDescriptionEnum(PaymentMethod.CreditCard); SpecialistProfileViewModel specialistProfile = new SpecialistProfileViewModel(); var specialist = Services.Users.GetUserById(specialistId); if (specialist != null) { specialistProfile = SpecialistDetailModelMapper.ModelMapper(specialist, CurrentUser.Id, Services); } return PartialView("_TalkNowPartial", specialistProfile); }
public ActionResult Index(string id, string timeZoneId) { try { if (!string.IsNullOrEmpty(timeZoneId)) { new SearchHandler(Services).SetClientTimeZone(timeZoneId); } SpecialistProfileViewModel model = new SpecialistProfileViewModel(); Guid specialistId = Guid.Empty; Guid.TryParse(id, out specialistId); var account = Services.Users.GetUserById(specialistId); if (account == null || !Role.Specialist.Equals(account.Role)) { return Redirect("/"); } //Anonymous user can view a specialist's profile so CurrentUser can be NULL Guid? customerId = null; if (CurrentUser != null) { customerId = CurrentUser.Id; } model = SpecialistDetailModelMapper.ModelMapper(account, customerId, Services); //convert list working schedule to display with time zone //cause they change the requirement - "specialist's profile" only show one "Specialization". var searcherLocation = Services.Search.GetPositionSearcher(customerId.GetValueOrDefault(Guid.Empty)); model.Proximity = Services.Search.GetDistance(searcherLocation, account); return View(model); } catch (Exception e) { Log.Error("Find a specialist by id", e); return View("ErrorPage"); } }
/// <summary> /// Convert List<SearchResultDto> to List<SpecialistProfileViewModel> /// used for API /// </summary> /// <param name="lstSpecialist"></param> /// <returns></returns> private List<SpecialistProfileViewModel> HandleDataFromAmazon(List<SearchResultDto> lstSpecialist) { List<SpecialistProfileViewModel> result = new List<SpecialistProfileViewModel>(); foreach (var searchDto in lstSpecialist) { SpecialistProfileViewModel specialistProfile = new SpecialistProfileViewModel(); var user = Services.Users.GetUserById(searchDto.User.Id); searchDto.User.Profile.Specializations = user.Profile.Specializations; Guid? customerId = Guid.Empty; if (CurrentUser != null) { customerId = CurrentUser.Id; } specialistProfile = SpecialistDetailModelMapper.ModelMapper(searchDto.User, customerId, Services); string timeZoneId = CurrentUser != null ? CurrentUser.DefaultTimeZoneId : TimeZoneInfo.Local.Id; specialistProfile.SpecialistDetail.ListStandardHour = TeleConsult.Web.Code.Helpers.DateTimeHelper.TimeZoneForWorkingSchedule( timeZoneId, specialistProfile.SpecialistDetail.ListStandardHour, Utilities.GetTimeZoneIdByName(searchDto.User.Locations[0].TimeZone)); if (searchDto.Proximity != 999999) { specialistProfile.Proximity = searchDto.Proximity; } result.Add(specialistProfile); } return result; }