public TripDetailPage(TripLogEntry tripLogEntry) { BindingContext = new DetailViewModel(tripLogEntry); InitializeComponent(); LoadData(); }
public async Task RemoveEntryAsync(TripLogEntry entry) //Remove { //url = "http://<service-name>.azurewebsites.net" + "/tables/entry/entry.id" var url = new Uri(_baseUri, $"/tables/entry/{entry.Id}"); var response = await SendRequestAsync <TripLogEntry>(url, HttpMethod.Delete, _headers); }
async Task ExecuteSaveCommand() { if (IsBusy) { return; } IsBusy = true; try { var newItem = new TripLogEntry { Title = Title, Latitude = Latitude, Longitude = Longitude, Date = Date, Rating = Rating, Notes = Notes }; await _tripLogService.AddEntryAsync(newItem); await NavService.GoBack(); } finally { IsBusy = false; } }
private async Task executeSaveCommand() { if (IsBusy) { return; } IsBusy = true; var newItem = new TripLogEntry { Title = this.Title, Latitude = this.Latitude, Longitude = this.Longitude, Date = this.Date, Rating = this.Rating, Notes = this.Notes }; try { await _tripLogService.AddEntryAsync(newItem); await NavService.GoBack(); } finally { IsBusy = false; } }
public async Task RemoveEntryAsync(TripLogEntry entry) { var url = new Uri(_baseUri, string.Format("/api/TripLogEntry/{0}", entry.Id)); var response = await SendRequestAsync <TripLogEntry>(url, HttpMethod.Delete, _headers); }
async Task ExecuteSaveCommand() { if (IsBusy) { return; } IsBusy = true; try { var newItem = new TripLogEntry { Title = Title, Latitude = Latitude, Longitude = Longitude, Date = Date, Rating = Rating, Notes = Notes }; // TODO: Persist Entry in a later chapter. // TODO: Remove this in Chapter 6 await Task.Delay(3000); await NavService.GoBack(); } finally { IsBusy = false; } }
public async Task <TripLogEntry> AddEntryAsync(TripLogEntry entry) { var url = new Uri(_baseUri, "/tables/entry"); var response = await SendRequestAsync <TripLogEntry>(url, HttpMethod.Post, _headers, entry); return(response); }
public void Delete_StoresMany_Then_DeletesExisting_RetrievesRemainingEntries() { // Arrange var entry1 = new TripLogEntry() { Title = "Title1" }; var entry2 = new TripLogEntry() { Title = "Title2" }; var entry3 = new TripLogEntry() { Title = "Title3" }; testee.Store(entry1); testee.Store(entry2); testee.Store(entry3); // Act var result = testee.Delete(entry2); // Assert Assert.IsTrue(result); var reminingEntries = testee.Retrieve().ToList(); Assert.AreEqual(reminingEntries.Count(), 2); Assert.IsFalse(reminingEntries.Contains(entry2)); }
public async Task <TripLogEntry> UpdateEntryAsync(TripLogEntry entry) { var url = new Uri(_baseUri, string.Format("/tables/entry/{0}", entry.Id)); var response = await SendRequestAsync <TripLogEntry>(url, new HttpMethod("PATCH"), _headers, entry); return(response); }
private async Task Save() { if (IsBusy) { return; } IsBusy = true; try { /**/ var newItem = new TripLogEntry { Title = Title, Latitude = Latitude, Longitude = Longitude, Date = Date, Rating = Rating, Notes = Notes }; // TODO: Persist entry await Task.Delay(3000); await NavService.GoBack(); } finally { IsBusy = false; } }
public DetailPage(TripLogEntry entry) { InitializeComponent(); try { map.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(entry.Latitude, entry.Longitude), Distance.FromMiles(.5))); map.Pins.Add(new Pin { Type = PinType.Place, Label = entry.Title, Position = new Position(entry.Latitude, entry.Longitude) }); title.Text = entry.Title; date.Text = entry.Date.ToString("M"); rating.Text = $"{entry.Rating} star rating"; notes.Text = entry.Notes; } catch { DisplayAlert("Cannot Connect", "I noticed that at the moment it works on iOS but not Android.", "Ok"); } }
async Task ExecuteSaveCommand() { if (IsBusy) { return; } IsBusy = true; try { var newItem = new TripLogEntry { Title = Title, Latitude = Latitude, Longitude = Longitude, Date = Date, Rating = Rating, Notes = Notes }; //Azure Data Access: Add new entry to Azure database await _tripLogDataService.AddEntryAsync(newItem); //Navigation Service : Go back to the main page await NavService.GoBack(); } finally { IsBusy = false; } }
public void Add(TripLogEntry value) { using (var transaction = Db.GetTransaction()) { transaction.Insert(TableName, value.Id, Serialize(value)); transaction.Commit(); } }
private void trips_ItemTapped(object sender, ItemTappedEventArgs e) { TripLogEntry trip = (TripLogEntry)e.Item; Navigation.PushAsync(new DetailPage()); trips.SelectedItem = null; }
public void MainViewModelInitializationThrowsTest() { var viewModel = new MainViewModel(TestInit.MockedTripLogDataService.Object); var entry = new TripLogEntry(); viewModel.Init(entry); }
public async Task NewEntryViewModelInitializationThrowsTest() { var viewModel = new NewEntryViewModel(TestInit.MockedGeoLocationService.Object, TestInit.MockedTripLogDataService.Object); var entry = new TripLogEntry(); await viewModel.Init(entry); }
public async Task <TripLogEntry> UpdateEntryAsync(TripLogEntry entry) //Update { //url = "http://<service-name>.azurewebsites.net" + "/tables/entry/entry.id" var url = new Uri(_baseUri, $"/tables/entry/{entry.Id}"); var response = await SendRequestAsync <TripLogEntry>(url, new HttpMethod("PATCH"), _headers, entry); return(response); }
public ContentPage Build(ViewType modelType, TripLogEntry entry) { var viewModel = _viewModelFactory.Build(modelType); viewModel.Init(entry); var view = _viewFactory.Build(modelType, viewModel); return(view); }
public async Task <TripLogEntry> AddEntryAsync(TripLogEntry entry) { var entryJson = JsonConvert.SerializeObject(entry); var result = await firebase .Child("TripLogs") .PostAsync(entryJson); return(entry); }
public Task NavigateToDetailPage(TripLogEntry entry) { var vm = this.viewModelFactory.BuildDetailPageViewModel(); vm.Init(entry); var page = this.viewFactory.BuildDetailPage(vm); return(navigation.PushAsync(page)); }
public async Task <TripLogEntry> AddEntryAsync(TripLogEntry entry) //Add { //url = "http://<service-name>.azurewebsites.net" + "/tables/entry" var url = new Uri(_baseUri, "/tables/entry"); var response = await SendRequestAsync <TripLogEntry>(url, HttpMethod.Post, _headers, entry); return(response); }
public async Task DetailViewModelInitializationThrowsTest() { var viewModel = new DetailViewModel(); var entry = new TripLogEntry(); await viewModel.Init(entry); Assert.AreEqual(entry, viewModel.Entry); }
public int DeleteItem(TripLogEntry entry) { if (entry._id != 0) { lock (locker) { return(_database.Delete <TripLogEntry>(entry._id)); } } return(entry._id); }
private async void trips_SelectionChanged(object sender, SelectionChangedEventArgs e) { TripLogEntry entry = e.CurrentSelection.FirstOrDefault() as TripLogEntry; if (entry != null) { await Navigation.PushAsync(new DetailPage(entry)); } // Clear selection after trips.SelectedItem = null; }
void ExecuteSaveCommand() { var newItem = new TripLogEntry { Title = Title, Latitude = Latitude, Longitude = Longitude, Date = Date, Rating = Rating, Notes = Notes }; }
public async Task <TripLogEntry> UpdateEntryAsync(TripLogEntry entry) { var entryJson = JsonConvert.SerializeObject(entry); var toUpdateTripLog = (await firebase .Child("TripLogs") .OnceAsync <TripLogEntry>()).Where(item => item.Object.Id == entry.Id).FirstOrDefault(); await firebase .Child("TripLogs/" + entry.Id) .PutAsync(entryJson); return(entry); }
public void AddSameElementTwiceToPersistencyTest() { var title1 = "Number1"; var entry = new TripLogEntry(title1); _db.Add(entry); _db.Add(entry); var allEntries = _db.GetAll(); Assert.AreEqual(1, allEntries.Count()); Assert.AreEqual(1, allEntries.Count(elem => elem.Title.Equals(title1))); }
public ActionResult <TripLogEntry> Post(TripLogEntry entry) { try { _persistency.Store(entry); return(CreatedAtAction(nameof(Post), new { id = entry.Title }, entry)); } catch (Exception e) { return(StatusCode(500, e?.Message)); } }
public IEnumerable <TripLogEntry> GetAll() { IList <TripLogEntry> result; using (var transaction = Db.GetTransaction()) { var select = transaction.SelectForward <string, string>(TableName); result = select.Select(elem => TripLogEntry.Deserialize(elem.Value)).ToList(); transaction.Commit(); } return(result); }
public IHttpActionResult Post([FromBody] TripLogEntry value) { try { _persistency.Add(value); _persistency.Dispose(); return(CreatedAtRoute("DefaultApi", new { id = value.Id }, value)); } catch (Exception e) { return(ThrowHttpResponseException(e)); } }