public async Task <IActionResult> Edit(int id, [Bind("TripId,TripPhoto,TripHistory,GuideId,CustomerId")] FishingTrip fishingTrip) { if (id != fishingTrip.TripId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(fishingTrip); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FishingTripExists(fishingTrip.TripId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CustomerId"] = new SelectList(_context.Customers, "CustomerId", "CustomerId", fishingTrip.CustomerId); ViewData["GuideId"] = new SelectList(_context.Guides, "GuideId", "GuideId", fishingTrip.GuideId); return(View(fishingTrip)); }
private void SetBindingContext(FishingTrip fishingTrip, Catch _catch) { FishingTrip = fishingTrip; Catch = _catch; BindingContext = _catch; if (_catch.Id.Equals("0")) { Catch.DateTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, 0); } else { IsEdit = true; FishType = Catch.FishType.Name; } if (Catch.Length > 0) { Length = Catch.Length.ToString("G"); } if (Catch.Weight > 0) { Weight = Catch.Weight.ToString("G"); } Date = Catch.DateTime.Date; Time = Catch.DateTime.TimeOfDay; }
private async void Delete_Clicked(object sender, EventArgs e) { FishingTrip fishingTrip = (sender as MenuItem)?.CommandParameter as FishingTrip; FishingTripManager manager = new FishingTripManager(); Response <FishingTrip> response = await manager.DeleteFishingTrip(fishingTrip); InformUserHelper <FishingTrip> informer = new InformUserHelper <FishingTrip>(response, this); informer.InformUserOfResponse(); await ReloadFishingTrips(); }
private async void TripsListView_ItemSelected(object sender, SelectedItemChangedEventArgs e) { if (e.SelectedItem == null) { return; } FishingTrip fishingTrip = e.SelectedItem as FishingTrip; await Navigation.PushAsync(new FishingTripDetailsPage(this, fishingTrip)); FishingTripsListView.SelectedItem = null; }
public async Task <IActionResult> Create([Bind("TripId,TripPhoto,TripHistory,GuideId,CustomerId")] FishingTrip fishingTrip) { if (ModelState.IsValid) { _context.Add(fishingTrip); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CustomerId"] = new SelectList(_context.Customers, "CustomerId", "CustomerId", fishingTrip.CustomerId); ViewData["GuideId"] = new SelectList(_context.Guides, "GuideId", "GuideId", fishingTrip.GuideId); return(View(fishingTrip)); }
public async Task <Response <FishingTrip> > AddCatch(FishingTrip fishingTrip, Catch aCatch) { Response <Catch> catchResponse = await _catchDao.CreateItem(aCatch); if (catchResponse.StatusCode != HttpStatusCode.OK) { return(new Response <FishingTrip> { StatusCode = catchResponse.StatusCode, Message = "Unsuccessful addCatch", Content = fishingTrip }); } fishingTrip.Catches.Add(catchResponse.Content); return(await UpdateFishingTrip(fishingTrip)); }
private void SetBindingContext(FishingTrip fishingTrip) { FishingTrip = fishingTrip; BindingContext = fishingTrip; SelectedWeather = fishingTrip.PredominantWeather; if (fishingTrip.Id.Equals("0")) { FishingTrip.DateTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, 0); } else { IsEdit = true; } Date = FishingTrip.DateTime.Date; Time = FishingTrip.DateTime.TimeOfDay; }
public async Task <Response <FishingTrip> > DeleteCatch(FishingTrip fishingTrip, Catch aCatch) { Response <Catch> catchResponse = await _catchDao.DeleteItem(aCatch); if (catchResponse.StatusCode != HttpStatusCode.OK) { return(new Response <FishingTrip> { StatusCode = catchResponse.StatusCode, Message = "Unsuccessful delete Catch", Content = fishingTrip }); } int index = fishingTrip.Catches.IndexOf(aCatch); fishingTrip.Catches.RemoveAt(index); return(await UpdateFishingTrip(fishingTrip)); }
public async Task RefreshData(FishingTrip fishingTrip) { SetBindingContext(fishingTrip); await Caller.ReloadFishingTrips(); }
public CatchesListPage(FishingTrip fishingTrip) { SetBindingContext(fishingTrip); InitializeComponent(); CatchesListView.ItemsSource = _catches; }
private async void Edit_Clicked(object sender, EventArgs e) { FishingTrip fishingTrip = (sender as MenuItem)?.CommandParameter as FishingTrip; await Navigation.PushAsync(new FishingTripsFormPage(this, fishingTrip)); }
private void SetBindingContext(FishingTrip fishingTrip) { FishingTrip = fishingTrip; _catches = new ObservableCollection <Catch>(FishingTrip.Catches); }
public static Task <CatchFormPage> CreateAsync(CatchesListPage caller, FishingTrip fishingTrip, Catch _catch) { CatchFormPage instance = new CatchFormPage(caller, fishingTrip, _catch); return(instance.InitializeAsync()); }
private void SetBindingContext(FishingTrip fishingTrip) { FishingTrip = fishingTrip; BindingContext = fishingTrip; NumberOfCatches = fishingTrip.Catches.Count; }
public async Task <Response <FishingTrip> > GetFishingTrip(FishingTrip fishingTrip) { return(await _fishingTripDao.GetItem(fishingTrip)); }
public FishingTripsFormPage(object caller, FishingTrip fishingTrip) { SetCaller(caller); SetBindingContext(fishingTrip); InitializeComponent(); }
public void RefreshList(FishingTrip fishingTrip) { SetBindingContext(fishingTrip); CatchesListView.ItemsSource = _catches; }
public async Task <Response <FishingTrip> > DeleteFishingTrip(FishingTrip fishingTrip) { return(await _fishingTripDao.DeleteItem(fishingTrip)); }
public CatchFormPage(CatchesListPage caller, FishingTrip fishingTrip, Catch _catch) { Caller = caller; SetBindingContext(fishingTrip, _catch); InitializeComponent(); }
public static Task <CatchFormPage> CreateAsync(CatchesListPage caller, FishingTrip fishingTrip) { return(CreateAsync(caller, fishingTrip, new Catch())); }
public FishingTripDetailsPage(FishingTripsPage caller, FishingTrip fishingTrip) { Caller = caller; SetBindingContext(fishingTrip); InitializeComponent(); }