public Task BindModelAsync(ModelBindingContext bindingContext)
        {
            if (bindingContext == null)
            {
                throw new ArgumentNullException(nameof(bindingContext));
            }

            var valueProviderResult = bindingContext.ValueProvider.GetValue(bindingContext.ModelName);

            if (valueProviderResult == ValueProviderResult.None)
            {
                return(_fallbackBinder.BindModelAsync(bindingContext));
            }

            var valueAsString = valueProviderResult.FirstValue;

            if (string.IsNullOrEmpty(valueAsString))
            {
                return(_fallbackBinder.BindModelAsync(bindingContext));
            }

            string[] latLongStr = valueAsString.Split(',');

            Point result = GeographyExtensions.CreatePoint(double.Parse(latLongStr[0]), double.Parse(latLongStr[1]));

            bindingContext.Result = ModelBindingResult.Success(result);

            return(Task.CompletedTask);
        }
Exemplo n.º 2
0
        public async Task <ApiResponse <IEnumerable <ClinicModel> > > GetAllClinicAsync(
            PaginationModel paging,
            double longitude,
            double latitude)
        {
            var location  = GeographyExtensions.CreatePoint(longitude, latitude);
            var pagingDto = _mapper.Mapper.Map <PagingDto>(paging);

            var clinicDtos = await _unitOfWork.ClinicRepository.GetAllClinicsAsync(pagingDto, location);

            return(ApiResponse <IEnumerable <ClinicModel> > .Ok(_mapper.Mapper.Map <IEnumerable <ClinicModel> >(clinicDtos)));
        }
Exemplo n.º 3
0
        public void CreateMappings(IMapperConfigurationExpression configuration)
        {
            configuration.CreateMap <LocationDto, Domain.Blog.Locations.Location>()
            .ForMember(bo => bo.UpdatedOn, dto => dto.Ignore())
            .ForMember(bo => bo.CreatedOn, dto => dto.Ignore())
            .ForMember(bo => bo.Latitude, dto => dto.MapFrom(s => s.GPSLocation != null ? s.GPSLocation.Y : (double?)null))
            .ForMember(bo => bo.Longitude, dto => dto.MapFrom(s => s.GPSLocation != null ? s.GPSLocation.X : (double?)null));

            configuration.CreateMap <Domain.Blog.Locations.Location, LocationDto>()
            .ForMember(dto => dto.GPSLocation, bo => bo.MapFrom(s => s.Latitude.HasValue && s.Longitude.HasValue ?
                                                                GeographyExtensions.CreatePoint(s.Latitude.Value, s.Longitude.Value) : default(Point)));
        }
Exemplo n.º 4
0
        public async Task <ApiResponse <IEnumerable <ClinicClinicianBase> > > GetClinicsWithCliniciansSortdetByDistanceAsync(
            double longitude,
            double latitude,
            ApiVersion version)
        {
            var geography = GeographyExtensions.CreatePoint(longitude, latitude);
            IEnumerable <ClinicLocationDto> sortedClinics = null;

            switch (version)
            {
            case ApiVersion.V1:
                sortedClinics = await _unitOfWork.ClinicClinicianRepository
                                .GetClinicsWithClinicianSortedByDistanceAsync_V1(geography);

                break;

            case ApiVersion.V2:
                sortedClinics = await _unitOfWork.ClinicClinicianRepository
                                .GetClinicsWithClinicianSortedByDistanceAsync_V2(geography);

                break;

            case ApiVersion.V3:
                sortedClinics = await _unitOfWork.ClinicClinicianRepository
                                .GetClinicsWithClinicianSortedByDistanceAsync_V3(geography);

                break;

            default:
                return(ApiResponse <IEnumerable <ClinicClinicianBase> > .BadRequest());
            }

            var result = new List <ClinicClinicianBase>();

            foreach (var clinic in sortedClinics)
            {
                result.Add(_mapper.Mapper.Map <ClinicWithDistanceModel>(clinic));
                foreach (var clinician in clinic.Clinicians)
                {
                    result.Add(_mapper.Mapper.Map <ClinicianWithDistanceModel>(clinician));
                }
            }

            return(ApiResponse <IEnumerable <ClinicClinicianBase> > .Ok(result));
        }
        public void CreateMappings(IMapperConfigurationExpression configuration)
        {
            configuration.CreateMap <ImageInfo, ImageInfoDto>()
            .ForMember(dto => dto.Id, bo => bo.MapFrom(s => s.Id))
            .ForMember(dto => dto.PlaceId, bo => bo.MapFrom(s => s.Comments))
            .ForMember(dto => dto.Caption, bo => bo.MapFrom(s => Path.GetFileNameWithoutExtension(s.FileInfo.Name)))
            .ForMember(dto => dto.DateTaken, bo => bo.MapFrom(s => s.DateTimeCreated))
            .ForMember(dto => dto.DateCreated, bo => bo.MapFrom(s => s.FileInfo.LastWriteTime))
            .ForMember(dto => dto.Image, bo => bo.MapFrom(s => s.FileInfo))
            .ForMember(dto => dto.GPSLocation, bo => bo.MapFrom(s => s.GPSLatitudeDegrees.HasValue && s.GPSLongitudeDegrees.HasValue ?
                                                                GeographyExtensions.CreatePoint(s.GPSLatitudeDegrees.Value, s.GPSLongitudeDegrees.Value) : default(Point)));

            configuration.CreateMap <ImageInfoDto, ImageInfo>()
            .ForMember(bo => bo.Comments, dto => dto.MapFrom(s => s.PlaceId))
            .ForMember(bo => bo.DateTimeCreated, dto => dto.MapFrom(s => s.DateTaken))
            .ForMember(bo => bo.GPSLatitudeDegrees, dto => dto.MapFrom(s => s.GPSLocation != null ? s.GPSLocation.Y : (double?)null))
            .ForMember(bo => bo.GPSLongitudeDegrees, dto => dto.MapFrom(s => s.GPSLocation != null ? s.GPSLocation.X : (double?)null));
        }