Esempio n. 1
0
 protected override void setJSON(JObject obj, BaseClassIfc host, SetJsonOptions options)
 {
     base.setJSON(obj, host, options);
     if (mBuildingAddress != null)
     {
         obj["BuildingAddress"] = BuildingAddress.getJson(this, options);
     }
 }
Esempio n. 2
0
 internal override void SetXML(XmlElement xml, BaseClassIfc host, Dictionary <int, XmlElement> processed)
 {
     base.SetXML(xml, host, processed);
     if (mBuildingAddress != null)
     {
         xml.AppendChild(BuildingAddress.GetXML(xml.OwnerDocument, "BuildingAddress", this, processed));
     }
 }
Esempio n. 3
0
        public async Task <int> InsertOrUpdateBuildingAsync(BuildingAddress buildingAddress)
        {
            ServerResponse <int> response = await this.Client.SendAsync <int>(HttpMethod.Post, "api/building", buildingAddress);

            if (response.Content == default(int))
            {
                throw new HmsException(response.ReasonPhrase);
            }

            return(response.Content);
        }
Esempio n. 4
0
        private static GeoObject GetCity(BuildingAddress buildingAddress, GeoPoint point)
        {
            var geocoderMetaData = new GeoMetaData(buildingAddress.City, GeoObjectKind.Locality)
            {
                Address = GetCityAddress(buildingAddress.City)
            };

            return(new GeoObject
            {
                GeocoderMetaData = geocoderMetaData,
                Point = point
            });
        }
Esempio n. 5
0
        public async Task <IHttpActionResult> Get(double latitude, double longitude)
        {
            try
            {
                BuildingAddress building = await this.BuildingService.GetBuildingAsync(new GeoPoint(longitude, latitude));

                return(this.Ok(building));
            }
            catch (Exception e)
            {
                return(new HttpActionResult(this, HttpStatusCode.BadRequest, e.Message));
            }
        }
Esempio n. 6
0
        private async Task OnLoadedAsync()
        {
            var profile = await this.ProfileDataService.GetCurrentProfileAsync();

            int buildingId      = profile.BuildingId.Value;
            var buildingAddress = await this.BuildingDataService.GetBuildingAsync(buildingId);

            var point = new GeoPoint(buildingAddress.Longitude, buildingAddress.Latitude);

            this.Address = new AddressWrapper(
                new Models.Address
            {
                City     = GetCity(buildingAddress, point),
                Street   = GetStreet(buildingAddress, point),
                Building = GetBuilding(buildingAddress, point)
            });

            this.PageContract = new PageControlContract(buildingAddress.PolyclinicRegion.PolyclinicId, this.MedicalSpecializationDataService);
            this.TotalRecords = await this.PageContract.GetTotalCountAsync(this.Filter);

            this.Address.PropertyChanged += async(sender, args) =>
            {
                if (args.PropertyName == nameof(this.Address.City))
                {
                    this.Address.Street = null;
                    return;
                }

                if (args.PropertyName == nameof(this.Address.Street))
                {
                    this.Address.Building = null;
                    return;
                }

                if (args.PropertyName == nameof(this.Address.Building))
                {
                    if (this.Address.Building == null)
                    {
                        this.TotalRecords = null;
                        this.Filter       = null;
                        return;
                    }

                    BuildingAddress ba = await this.BuildingDataService.GetBuildingAsync(this.Address.Building.Point);

                    this.PageContract = new PageControlContract(ba.PolyclinicRegion.PolyclinicId, this.MedicalSpecializationDataService);
                    this.TotalRecords = await this.PageContract.GetTotalCountAsync(this.Filter);
                }
            };
        }
Esempio n. 7
0
 protected override void setJSON(JObject obj, BaseClassIfc host, SetJsonOptions options)
 {
     base.setJSON(obj, host, options);
     if (!double.IsNaN(mElevationOfRefHeight))
     {
         obj["ElevationOfRefHeight"] = ElevationOfRefHeight.ToString();
     }
     if (!double.IsNaN(mElevationOfTerrain))
     {
         obj["ElevationOfTerrain"] = ElevationOfTerrain.ToString();
     }
     if (mBuildingAddress != null)
     {
         obj["BuildingAddress"] = BuildingAddress.getJson(this, options);
     }
 }
Esempio n. 8
0
 internal override void SetXML(XmlElement xml, BaseClassIfc host, Dictionary <int, XmlElement> processed)
 {
     base.SetXML(xml, host, processed);
     if (!double.IsNaN(mElevationOfRefHeight))
     {
         xml.SetAttribute("ElevationOfRefHeight", mElevationOfRefHeight.ToString());
     }
     if (!double.IsNaN(mElevationOfTerrain))
     {
         xml.SetAttribute("ElevationOfTerrain", mElevationOfTerrain.ToString());
     }
     if (mBuildingAddress > 0)
     {
         xml.AppendChild(BuildingAddress.GetXML(xml.OwnerDocument, "BuildingAddress", this, processed));
     }
 }
Esempio n. 9
0
 protected override void setJSON(JObject obj, BaseClassIfc host, HashSet <int> processed)
 {
     base.setJSON(obj, host, processed);
     if (!double.IsNaN(mElevationOfRefHeight))
     {
         obj["ElevationOfRefHeight"] = ElevationOfRefHeight.ToString();
     }
     if (!double.IsNaN(mElevationOfTerrain))
     {
         obj["ElevationOfTerrain"] = ElevationOfTerrain.ToString();
     }
     if (mBuildingAddress > 0)
     {
         obj["BuildingAddress"] = BuildingAddress.getJson(this, processed);
     }
 }
Esempio n. 10
0
        private static GeoObject GetStreet(BuildingAddress buildingAddress, GeoPoint point)
        {
            var address = GetCityAddress(buildingAddress.City);

            address.Street = buildingAddress.Street;

            var geocoderMetaData = new GeoMetaData(buildingAddress.Street, GeoObjectKind.Street)
            {
                Address = address
            };

            return(new GeoObject
            {
                GeocoderMetaData = geocoderMetaData,
                Point = point
            });
        }
Esempio n. 11
0
        private static GeoObject GetBuilding(BuildingAddress buildingAddress, GeoPoint point)
        {
            var address = new Address
            {
                House = buildingAddress.Building
            };

            var geocoderMetaData = new GeoMetaData(buildingAddress.Building, GeoObjectKind.House)
            {
                Address = address
            };

            return(new GeoObject
            {
                GeocoderMetaData = geocoderMetaData,
                Point = point
            });
        }
Esempio n. 12
0
        public async Task <IHttpActionResult> Post([FromBody] BuildingAddress building)
        {
            try
            {
                if (building == null)
                {
                    throw new ArgumentNullException($"{nameof(building)} must be not null");
                }

                int id = await this.BuildingService.InsertOrUpdateBuildingAsync(building);

                return(this.Ok(id));
            }
            catch (Exception e)
            {
                return(new HttpActionResult(this, HttpStatusCode.BadRequest, e.Message));
            }
        }
Esempio n. 13
0
        public async Task <IHttpActionResult> Get(int id)
        {
            try
            {
                if (id <= 0)
                {
                    throw new ActivationException($"{nameof(id)} must be positive");
                }

                BuildingAddress building = await this.BuildingService.GetBuildingAsync(id);

                return(this.Ok(building));
            }
            catch (Exception e)
            {
                return(new HttpActionResult(this, HttpStatusCode.BadRequest, e.Message));
            }
        }
        public async Task <int> InsertOrUpdateBuildingAsync(BuildingAddress address)
        {
            try
            {
                using (var connection = new SqlConnection(this.ConnectionString))
                {
                    await connection.OpenAsync();

                    int regionId = await this.RegionRepository.InsertOrUpdateRegionAsync(address.PolyclinicRegion);

                    var command = @"
                    BEGIN TRAN
	                    IF EXISTS (SELECT [Id] FROM [BuildingAddress] WHERE [Id] = @Id) 
		                    BEGIN
			                    UPDATE [BuildingAddress] WITH (SERIALIZABLE) 
						                SET 
	                                        [City] = @City, 
	                                        [Street] = @Street, 
	                                        [Building] = @Building,
	                                        [Latitude] = @Latitude,
	                                        [Longitude] = @Longitude, 
	                                        [PolyclinicRegionId] = @regionId
                                        WHERE [Id] = @Id
                                        SELECT @Id
		                    END
	                    ELSE
		                    BEGIN
			                    INSERT INTO [BuildingAddress] ([City], [Street], [Building], [Latitude], [Longitude], [PolyclinicRegionId]) OUTPUT INSERTED.ID VALUES 
                                                        (@City, @Street, @Building, @Latitude, @Longitude, @regionId)
		                    END
                    COMMIT TRAN";

                    var id = await connection.QueryFirstOrDefaultAsync <int>(command, new { address.Id, address.City, address.Street, address.Building, address.Latitude, address.Longitude, regionId });

                    return(id);
                }
            }
            catch (Exception e)
            {
                throw new ArgumentException(e.Message);
            }
        }
        private async Task CreateAndSaveProfileAsync()
        {
            try
            {
                int userId = this.ProfileService.Client.UserId.Value;

                BuildingAddress buildingAddress = await this.BuildingService.GetBuildingAsync(this.Address.Building.Point);

                Profile model = this.Profile.Model;

                model.UserId     = userId;
                model.BuildingId = buildingAddress.Id;

                await this.ProfileService.InsertOrUpdateProfileAsync(model);
            }
            catch (Exception e)
            {
                await this.DialogCoordinator.ShowMessageAsync(this, "Oops", e.Message);

                throw;
            }
        }
Esempio n. 16
0
        public async Task <BuildingAddress> GetBuildingAsync(GeoPoint geoPoint)
        {
            GeoObjectCollection objectCollection =
                await this.Geocoder.ReverseGeocodeAsync(geoPoint, GeoObjectKind.House, 1, LangType.RU);

            GeoObject geoObject = objectCollection.First();
            Address   address   = geoObject.GeocoderMetaData.Address;

            int buildingId =
                await this.BuildingRepository.GetBuildingIdOrDefaultAsync(geoPoint.Latitude, geoPoint.Longitude);

            if (buildingId != default(int))
            {
                return(await this.BuildingRepository.GetBuildingAsync(buildingId));
            }

            int id = await this.PolyclinicRegionProvider.GetPolyclinicRegionIdAsync(address);

            PolyclinicRegion region = await this.PolyclinicRegionService.GetRegionAsync(id);

            BuildingAddress building = new BuildingAddress
            {
                City             = $"{address.Locality}, {address.Province}, {address.Country}",
                Street           = address.Street,
                Building         = address.House,
                Latitude         = geoPoint.Latitude,
                Longitude        = geoPoint.Longitude,
                PolyclinicRegion = region
            };

            int insertedBuildingId = await this.InsertOrUpdateBuildingAsync(building);

            building.Id = insertedBuildingId;

            return(building);
        }
Esempio n. 17
0
 public async Task <int> InsertOrUpdateBuildingAsync(BuildingAddress buildingAddress)
 {
     return(await this.BuildingRepository.InsertOrUpdateBuildingAsync(buildingAddress));
 }