private async void ExecuteSaveStation() { Station stationToEdit = new Station(); stationToEdit.StationId = this.selectedStation.StationId; stationToEdit.Name = this.StationName; stationToEdit.Latitude = this.Latitude; stationToEdit.Longitude = this.Longitude; stationToEdit.StationTypeId = this.SelectedStationType.StationTypeId; stationToEdit.AddressId = this.selectedStation.AddressId; stationToEdit.UserId = this.selectedStation.UserId; bool result = false; try { Address a = await addressManager.GetAddressForId(stationToEdit.AddressId); a.CommunityId = this.selectedCommunity.CommunityId; a.Location = this.addressString; result = await addressManager.UpdateAddress(a); } catch (BusinessSqlException ex) { notifierManager.ShowError(ex.Message); } if (!result) { notifierManager.ShowError("Failed to update Station!"); } else { notifierManager.ShowSuccess("Update successful"); } try { result = await stationManager.UpdateStation(stationToEdit); } catch (BusinessSqlException ex) { notifierManager.ShowError(ex.Message); } if (!result) { notifierManager.ShowError("Failed to update Station!"); } /* Reload station data */ await LoadStations(); this.SelectedStation = this.Stations.Where(s => s.StationId == stationToEdit.StationId).Single(); RaisePropertyChanged(nameof(SelectedStation)); RaisePropertyChanged(nameof(Stations)); }
public void TestGetAddressForId() { Mock <IAddressDao> dao = new Mock <IAddressDao>(MockBehavior.Loose); Task <Address> res5 = new Task <Address>(() => null); res5.RunSynchronously(); dao.Setup(x => x.FindByIdAsync(It.IsAny <int>())).Returns(res5); AddressManager m = new AddressManager(null, null, null, null, dao.Object); Address a = m.GetAddressForId(1).Result; dao.Verify(c => c.FindByIdAsync(It.IsAny <int>()), Times.Once); }