public async Task UpdateTravelPointOfInterest(int id, TravelPointOfInterest tl) { if (tl == null) { throw new ArgumentNullException(nameof(tl)); } _context.Points.Update(tl); //TravelListItem travelList = await _context.TravelLists.FirstAsync(p => p.TravelListItemID == id); //travelList = tl; await _context.SaveChangesAsync(); }
public async Task <TravelPointOfInterest> CreateTravelPointOfInterest(TravelPointOfInterest tl) { if (tl == null) { throw new ArgumentNullException(nameof(tl)); } _context.Points.Add(tl); await _context.SaveChangesAsync(); return(await _context.Points.AsNoTracking().Include(x => x.ConnectedStartRoutes).Include(x => x.ConnectedEndRoutes).FirstOrDefaultAsync(p => p.TravelPointOfInterestID == tl.TravelPointOfInterestID)); }
public PointOfInterest(TravelPointOfInterest point) { TravelPointOfInterestID = point.TravelPointOfInterestID; Name = point.Name; ImageSourceUri = new Uri("ms-appx:///Assets/MapPin.png"); NormalizedAnchorPoint = new Point(0.5, 1); Latitude = (decimal)point.Latitude; Longitude = (decimal)point.Longitude; Location = new Geopoint(new BasicGeoposition() { Latitude = (double)point.Latitude, Longitude = (double)point.Longitude }); TravelListItemID = point.TravelListItemID; ConnectedStartRoutes = point.ConnectedStartRoutes; ConnectedEndRoutes = point.ConnectedEndRoutes; }
public async Task DeleteTravelPointOfInterest(TravelPointOfInterest tl) { if (tl == null) { throw new ArgumentNullException(nameof(tl)); } foreach (TravelRoute route in tl.ConnectedStartRoutes) { _context.Routes.Remove(route); } foreach (TravelRoute route in tl.ConnectedEndRoutes) { _context.Routes.Remove(route); } _context.Points.Remove(tl); await _context.SaveChangesAsync(); }
public async Task UpdateTravelPointOfInterest(int id, TravelPointOfInterest tl) => await _http.PutAsync <TravelPointOfInterest, TravelPointOfInterest>($"TravelPointOfInterests/{id}", tl);
public async Task DeleteTravelPointOfInterest(TravelPointOfInterest tl) => await _http.DeleteAsync("TravelPointOfInterests", tl.TravelPointOfInterestID);
public async Task <TravelPointOfInterest> CreateTravelPointOfInterest(TravelPointOfInterest tl) => await _http.PostAsync <TravelPointOfInterest, TravelPointOfInterest>("TravelPointOfInterests", tl);
private async Task CreateTravelListByName(string name, string imageName, int days) { try { var newTravelListItem = new TravelListItem(); newTravelListItem.UserId = LoginPage.account.Id; newTravelListItem.Name = name; newTravelListItem.Description = name + " Description"; newTravelListItem.StartDate = DateTime.Now.AddDays(days); newTravelListItem.EndDate = DateTime.Now.AddDays(days + 10);; newTravelListItem.Country = name; Country country = App.ViewModel.Countries.Where(x => x.Name == name).First(); newTravelListItem.Latitude = country.LatLng[0]; newTravelListItem.Longitude = country.LatLng[1]; var item = await CreateTravelList(newTravelListItem); await CreateImageByName(imageName + "1", item); await CreateImageByName(imageName + "2", item); TravelPointOfInterest start = null; TravelPointOfInterest end = null; if (string.Equals(name, "Spain")) { start = await CreateTravelPointOfInterest(new TravelPointOfInterest() { Name = "Bilbao", Latitude = 43.24M, Longitude = -2.92m, TravelListItemID = item.TravelListItemID }); end = await CreateTravelPointOfInterest(new TravelPointOfInterest() { Name = "Pamplona", Latitude = 42.78M, Longitude = -1.63m, TravelListItemID = item.TravelListItemID }); } else if (string.Equals(name, "Costa Rica")) { start = await CreateTravelPointOfInterest(new TravelPointOfInterest() { Name = "San Jose", Latitude = 9.93M, Longitude = -84.06m, TravelListItemID = item.TravelListItemID }); end = await CreateTravelPointOfInterest(new TravelPointOfInterest() { Name = "Orotina", Latitude = 9.91M, Longitude = -84.52m, TravelListItemID = item.TravelListItemID }); } else if (string.Equals(name, "Japan")) { start = await CreateTravelPointOfInterest(new TravelPointOfInterest() { Name = "Tokyo", Latitude = 35.68M, Longitude = 139.73m, TravelListItemID = item.TravelListItemID }); end = await CreateTravelPointOfInterest(new TravelPointOfInterest() { Name = "Nagano", Latitude = 36.59M, Longitude = 138.12m, TravelListItemID = item.TravelListItemID }); } if (start != null && end != null) { await CreateTravelRoute(new TravelRoute() { Driving = true, StartTravelPointOfInterestID = start.TravelPointOfInterestID, EndTravelPointOfInterestID = end.TravelPointOfInterestID, TravelListItemID = item.TravelListItemID, }); } } catch (Exception) { } }
private async Task <TravelPointOfInterest> CreateTravelPointOfInterest(TravelPointOfInterest travelPointOfInterest) { return(await App.Repository.Points.CreateTravelPointOfInterest(travelPointOfInterest)); }