public async Task <Location> UpdateLocation(LocationBody locationBody, int locationId)
        {
            Location oldLocation = await locationRepository.ReadAsync(locationId);

            // create location
            Location location = new Location
            {
                Id   = locationId,
                Name = locationBody.Name,
                City = locationBody.City,
                Lat  = locationBody.Lat,
                Lng  = locationBody.Lng
            };

            if (locationBody.Image != null)
            {
                // save image to blob
                string imageName = await azureService.saveImageToBlobStorage(locationBody.Image);

                location.Image = imageName;

                // delete old image
                azureService.deleteImageFromBlobStorage(oldLocation.Image);
            }

            // save location to database
            Location updatedLocation = await locationRepository.UpdateAsync(location);

            return(updatedLocation);
        }
        public async Task <int> CreateLocation(LocationBody locationBody)
        {
            // save image to blob
            string imageName = await azureService.saveImageToBlobStorage(locationBody.Image);

            // create new location
            Location newLocation = new Location
            {
                Name  = locationBody.Name,
                City  = locationBody.City,
                Lat   = locationBody.Lat,
                Lng   = locationBody.Lng,
                Image = imageName
            };

            // save location to database
            await locationRepository.CreateAsync(newLocation);

            return(newLocation.Id);
        }
Exemple #3
0
 private void  RecieveLocationMessage(LocationBody body)
 {
     AppendRevHtml(String.Format("<div>我现在的位置是{0}(经度:{1};纬度:{2})</div>", body.addr, body.lat, body.lng));
 }