Beispiel #1
0
        public static void AddTrip(Trip trip, int vehicleId, int employeeId)
        {
            using (var db = new TripContext())
            {
                var vehicles_ = db.Vehicles.
                                Where(vehicle => (vehicle.VehicleId == vehicleId));

                List <Vehicle> vehicles__ = new List <Vehicle>();
                foreach (var vehicle in vehicles_)
                {
                    vehicles__.Add(vehicle);
                }
                Vehicle _vehicle = vehicles__.ElementAt(0);

                var employees_ = db.Employees.
                                 Where(employee => (employee.EmployeeId == employeeId));

                List <Employee> employees__ = new List <Employee>();
                foreach (var employee in employees_)
                {
                    employees__.Add(employee);
                }
                Employee _employee = employees__.ElementAt(0);

                trip.Employee = _employee;
                trip.Vehicle  = _vehicle;

                db.Add(trip);

                db.SaveChanges();
            }
        }
Beispiel #2
0
 public static void AddVehicle(Vehicle vehicle)
 {
     using (var db = new TripContext())
     {
         db.Add(vehicle);
         db.SaveChanges();
     }
 }
Beispiel #3
0
 public IActionResult Post([FromBody] Trip value)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     _context.Add(value);
     _context.SaveChanges();
     return(Ok());
 }
        public async Task <IActionResult> Create([Bind("Id,ConfirmationNumber,LodgingName,Address,AddressSuburb,AddressCity,AddressRegion,AddressPostcode,AddressCountry,ArrivalDate,ArrivalTime,DepartureDate,DepartureTime,NumOfGuests,NumOfRooms,RoomDescription,TripId")] Lodging lodging)
        {
            if (ModelState.IsValid)
            {
                _context.Add(lodging);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Details", new { lodging.Id }));
            }
            return(View(lodging));
        }
        public async Task <IActionResult> Create([Bind("Id,TypeOfTransport,CarrierName,ConfirmationNumber,DepartureAddress,DepartureSuburb,DepartureCity,DepartureRegion,DeparturePostcode,DepartureCountry,DepartureDate,DepartureTime,ArrivalDate,ArrivalTime,ArrivalAddress,ArrivalSuburb,ArrivalCity,ArrivalRegion,ArrivalPostcode,ArrivalCountry,TripId")] OtherTransportation otherTransportation)
        {
            if (ModelState.IsValid)
            {
                _context.Add(otherTransportation);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Details", new { otherTransportation.Id }));
            }
            return(View(otherTransportation));
        }
        public async Task <IActionResult> Create([Bind("Id,RestaurantName,Address,Suburb,City,Region,Postcode,Country,Description,Date,Time,Cuisine,NumberInParty,ConfirmationNumber,HoursOfOperation,DressCode,PriceRange,TripId")] Restaurant restaurant)
        {
            if (ModelState.IsValid)
            {
                _context.Add(restaurant);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Details", new { restaurant.Id }));
            }
            return(View(restaurant));
        }
Beispiel #7
0
        public async Task <IActionResult> Create([Bind("TripID,Country,City,Price,Duration,GuideID")] Trip trip)
        {
            if (ModelState.IsValid)
            {
                _context.Add(trip);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(trip));
        }
Beispiel #8
0
        public async Task <IActionResult> Create([Bind("Id,Title")] Todo todo)
        {
            if (ModelState.IsValid)
            {
                _context.Add(todo);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(todo));
        }
Beispiel #9
0
        public async Task <IActionResult> Create([Bind("Id,SuppplierName,ConfirmationNumber,PickupName,PickupAddress,PickupSuburb,PickupCity,PickupRegion,PickupPostcode,PickupCountry,DropoffAddress,DropoffSuburb,DropoffCity,DropoffRegion,DropoffPostcode,DropoffCountry,PickupDate,PickupTime,DropoffDate,DropoffTime,SupplierPhoneNumber,TripId,DropoffCheckbox,Door,Seats,Transmisson,LargeBag,SmallBag,Litres")] CarRental carRental)
        {
            if (ModelState.IsValid)
            {
                _context.Add(carRental);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Details", new { carRental.Id }));
            }
            return(View(carRental));
        }
Beispiel #10
0
        public async Task <IActionResult> Create([Bind("Id,TypeOfActivity,ConfirmationNumber,SupplierName,Description,StartDate,StartTime,EndDate,EndTime,Address,Suburb,City,Region,Postcode,Country,NumOfPeopleAttending,TripId")] ActivityTask activityTask)
        {
            if (ModelState.IsValid)
            {
                _context.Add(activityTask);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Details", new { activityTask.Id }));
            }
            return(View(activityTask));
        }
Beispiel #11
0
        public async Task <IActionResult> Create([Bind("Id,Name,IsChecked,TodoId")] Item item)
        {
            if (ModelState.IsValid)
            {
                _context.Add(item);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(item));
        }
Beispiel #12
0
        public async Task <IActionResult> Create([Bind("Id,Name,DestinationCity,DestinationCountry,StartDate,FinishDate,Description")] Trip trip)
        {
            if (ModelState.IsValid)
            {
                _context.Add(trip);

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(trip));
        }
Beispiel #13
0
 public void Add(Trip trip)
 {
     _context.Add(trip);
 }