public void DeleteSyncPerson(FamousPerson famousePerson)
 {
     //删除
     FamousPersons.Remove(famousePerson);
     //同步Graphic
     DeletePersonGraphic(famousePerson);
 }
        private void DeletePersonGraphic(FamousPerson person)
        {
            var point = new MapPoint(person.BornX, person.BornY);
            //  var graphic = new Graphic(point,(Symbol)GetGloabelResorce("RedMarkerSymbolCircle");
            var graphic = personsLayers.Graphics.Where(p => ((int)p.Attributes["PersonId"]) == person.FamousPersonId).FirstOrDefault();

            if (graphic != null)
            {
                personsLayers.Graphics.Remove(graphic);
            }
        }
        private void AddPersonGraphic(FamousPerson person)
        {
            var point   = new MapPoint(person.BornX, person.BornY);
            var graphic = new Graphic(point, (Symbol)GetGloabelResorce("RedMarkerSymbolCircle"));

            graphic.Attributes["PersonId"]   = person.FamousPersonId;
            graphic.Attributes["PersonName"] = person.PersonName;
            graphic.Attributes["Place"]      = person.BornPlace;
            graphic.Attributes["BornDate"]   = person.BornDate;
            personsLayers.Dispatcher.Invoke(() =>
            {
                personsLayers.Graphics.Add(graphic);
            });
        }
        public async void UpdateAsync(FamousPerson famousePerson)
        {
            var address = string.Format("{0}/{1}", UpdateUrl, famousePerson.FamousPersonId);

            using (var httpClient = new HttpClient())
            {
                var response = await httpClient.PostAsJsonAsync <FamousPerson>(address, famousePerson);

                if (!response.IsSuccessStatusCode)
                {
                    var apiErrorModel = await response.Content.ReadAsAsync <ApiErrorModel>();

                    throw new ApiErrorException(apiErrorModel);
                }
            }
        }
        // TODO: Add properties using the mvvmprop code snippet

        // TODO: Add methods that will be called by the view
        public async void DeleteAsync()
        {
            if (SelectFamousePerson != null)
            {
                try
                {
                    await personService.DeleteAsync(selectFamousePerson.FamousPersonId);

                    ViewModelLocator.MapPageViewModelInstance.DeleteSyncPerson(selectFamousePerson);
                    SelectFamousePerson = null;
                    MessageBox.Show("删除成功");
                }
                catch (Exception e)
                {
                    System.Windows.MessageBox.Show(e.Message);
                }
            }
        }
        public async Task <FamousPerson> SaveAsync(FamousPerson famousePerson, string pictureName)
        {
            //var address=string
            using (var httpClient = new HttpClient())
            {
                var response = await httpClient.PostAsJsonAsync(SaveUrl, famousePerson);

                if (response.IsSuccessStatusCode)
                {
                    return(await response.Content.ReadAsAsync <FamousPerson>());
                }
                else
                {
                    var apiErrorModel = await response.Content.ReadAsAsync <ApiErrorModel>();

                    throw new ApiErrorException(apiErrorModel);
                }
            }
        }
Beispiel #7
0
        public static FamousPerson ConvertToDo(FamousPersonInfo famousPersonInfo)
        {
            if (famousPersonInfo == null)
            {
                return(null);
            }
            var person = new FamousPerson()
            {
                BornDate       = famousPersonInfo.BornDate,
                BornPlace      = famousPersonInfo.BornPlace,
                BornX          = famousPersonInfo.BornX,
                BornY          = famousPersonInfo.BornY,
                DeadDate       = famousPersonInfo.DeadDate,
                FamousPersonId = famousPersonInfo.FamousPersonId,
                Province       = famousPersonInfo.Province,
                Gender         = famousPersonInfo.Gender,
                Nation         = famousPersonInfo.Nation,
                PersonName     = famousPersonInfo.PersonName,
            };

            return(person);
        }
Beispiel #8
0
        public static FamousPersonInfo ConvertToDto(FamousPerson famousPerson, IEnumerable <Int32> typeIds)
        {
            if (famousPerson == null)
            {
                return(null);
            }
            var personInfo = new FamousPersonInfo()
            {
                BornDate       = famousPerson.BornDate,
                BornPlace      = famousPerson.BornPlace,
                BornX          = famousPerson.BornX,
                BornY          = famousPerson.BornY,
                DeadDate       = famousPerson.DeadDate,
                FamousPersonId = famousPerson.FamousPersonId,
                Province       = famousPerson.Province,
                Gender         = famousPerson.Gender,
                Nation         = famousPerson.Nation,
                PersonName     = famousPerson.PersonName,
                PersonTypeIds  = typeIds
            };

            return(personInfo);
        }
Beispiel #9
0
 public async Task <FamousPerson> SaveAsync(FamousPerson famousePerson)
 {
     return(await HttpClientUtils.PostJsonAsync <FamousPerson, FamousPerson>(SAVE_URL, famousePerson));
 }
Beispiel #10
0
 public async Task UpdateAsync(FamousPerson famousePerson)
 {
     var address = string.Format("{0}/{1}", UPDATE_URL, famousePerson.FamousPersonId);
     await HttpClientUtils.PostJsonNoReturnAsync <FamousPerson>(address, famousePerson);
 }
Beispiel #11
0
 public void Initial()
 {
     IsMale       = true;
     SelectImg    = null;
     FamousPerson = new FamousPerson();
 }
 public void EdiSyncPerson(FamousPerson famouserPerson)
 {
     //同步Graphic
     EditPersonGraphic(famouserPerson);
 }
 public void AddSyncPerson(FamousPerson famousePerson)
 {
     this.FamousPersons.Add(famousePerson);
     //同步Graphic
     AddPersonGraphic(famousePerson);
 }