Ejemplo n.º 1
0
        public static List <TripModel> CreateNewTrip()
        {
            AddTrip addTrip = new AddTrip();

            addTrip.ShowDialog();
            if (addTrip.DialogResult == true)
            {
                if (NewTrip.Count == 1)
                {
                    SaveNewTrip(NewTrip[0]);
                    List <TripModel> trip = new List <TripModel>(NewTrip);
                    NewTrip.Clear();
                    return(trip);
                }
                else if (NewTrip.Count == 2)
                {
                    NewTrip.ForEach(nt => SaveNewTrip(nt));
                    List <TripModel> trip = new List <TripModel>(NewTrip);
                    NewTrip.Clear();
                    return(trip);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <AddTrip> > PostAddTrip(AddTrip addTrip)
        {
            _context.addTrips.Add(addTrip);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetAddTrip", new { id = addTrip.tid }, addTrip));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> PutAddTrip(int id, AddTrip addTrip)
        {
            if (id != addTrip.tid)
            {
                return(BadRequest());
            }

            _context.Entry(addTrip).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AddTripExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        private void AddTrip_Button_Click(object sender, RoutedEventArgs e)
        {
            AddTrip addTrip = new AddTrip((IKilometersCard)KilometersCard_ComboBox.SelectedItem);

            addTrip.Driver_ComboBox.ItemsSource      = _dataCollection.Drivers;
            addTrip.Project_ComboBox.ItemsSource     = _dataCollection.Projects;
            addTrip.Keeper_ComboBox.ItemsSource      = _dataCollection.Employees;
            addTrip.Destination_ComboBox.ItemsSource = _dataCollection.Destinations;
            addTrip.Show();
        }