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));
        }
예제 #2
0
        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;
        }
예제 #3
0
        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();
        }
예제 #4
0
        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));
        }
예제 #6
0
        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));
        }
예제 #7
0
        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;
        }
예제 #8
0
        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));
        }
예제 #9
0
 public async Task RefreshData(FishingTrip fishingTrip)
 {
     SetBindingContext(fishingTrip);
     await Caller.ReloadFishingTrips();
 }
예제 #10
0
 public CatchesListPage(FishingTrip fishingTrip)
 {
     SetBindingContext(fishingTrip);
     InitializeComponent();
     CatchesListView.ItemsSource = _catches;
 }
예제 #11
0
 private async void Edit_Clicked(object sender, EventArgs e)
 {
     FishingTrip fishingTrip = (sender as MenuItem)?.CommandParameter as FishingTrip;
     await Navigation.PushAsync(new FishingTripsFormPage(this, fishingTrip));
 }
예제 #12
0
 private void SetBindingContext(FishingTrip fishingTrip)
 {
     FishingTrip = fishingTrip;
     _catches    = new ObservableCollection <Catch>(FishingTrip.Catches);
 }
예제 #13
0
        public static Task <CatchFormPage> CreateAsync(CatchesListPage caller, FishingTrip fishingTrip, Catch _catch)
        {
            CatchFormPage instance = new CatchFormPage(caller, fishingTrip, _catch);

            return(instance.InitializeAsync());
        }
예제 #14
0
 private void SetBindingContext(FishingTrip fishingTrip)
 {
     FishingTrip     = fishingTrip;
     BindingContext  = fishingTrip;
     NumberOfCatches = fishingTrip.Catches.Count;
 }
예제 #15
0
 public async Task <Response <FishingTrip> > GetFishingTrip(FishingTrip fishingTrip)
 {
     return(await _fishingTripDao.GetItem(fishingTrip));
 }
예제 #16
0
 public FishingTripsFormPage(object caller, FishingTrip fishingTrip)
 {
     SetCaller(caller);
     SetBindingContext(fishingTrip);
     InitializeComponent();
 }
예제 #17
0
 public void RefreshList(FishingTrip fishingTrip)
 {
     SetBindingContext(fishingTrip);
     CatchesListView.ItemsSource = _catches;
 }
예제 #18
0
 public async Task <Response <FishingTrip> > DeleteFishingTrip(FishingTrip fishingTrip)
 {
     return(await _fishingTripDao.DeleteItem(fishingTrip));
 }
예제 #19
0
 public CatchFormPage(CatchesListPage caller, FishingTrip fishingTrip, Catch _catch)
 {
     Caller = caller;
     SetBindingContext(fishingTrip, _catch);
     InitializeComponent();
 }
예제 #20
0
 public static Task <CatchFormPage> CreateAsync(CatchesListPage caller, FishingTrip fishingTrip)
 {
     return(CreateAsync(caller, fishingTrip, new Catch()));
 }
예제 #21
0
 public FishingTripDetailsPage(FishingTripsPage caller, FishingTrip fishingTrip)
 {
     Caller = caller;
     SetBindingContext(fishingTrip);
     InitializeComponent();
 }