public BookingRequest(BookingDTO bookingDto, RideDTO rideDto, EmployeeDTO employeeDto, ClientDTO clientDto) { BookingDto = bookingDto; RideDto = rideDto; EmployeeDto = employeeDto; ClientDto = clientDto; }
public async Task <RideDTO> EndRide(Ride ride, RideDTO currentRide) { if (ride != null && ride.RideStatus != null && ride.RideStatus.Code != Core.Constant.RideStatus.Waiting && currentRide != null && currentRide.Destination != null) { using (var trans = this.UnitOfWork.DBContext.Database.BeginTransaction()) { LocationLagLon destination = await this.UnitOfWork.LocationLagLonRepository.Create(currentRide.Destination.ConvertToEntity()); await this.UnitOfWork.SaveAsync(); ride.DestinationId = destination.Id; await this.UnitOfWork.RideRepository.Update(ride); await this.UnitOfWork.SaveAsync(); trans.Commit(); return(await ChangeStatusToWaitingForPayment(ride.Id)); } } else { return(null); } }
public static Ride GetFromDto(RideDTO rideDto) { return(new Ride { Id = rideDto.Id, Destination = rideDto.Destination, Date = rideDto.Date, Hour = rideDto.Hour }); }
public ActionResult <RideDTO> PostRide(RideDTO ride) { if (ride == null) { return(NotFound()); } _rideRepository.Add(ride); _rideRepository.SaveChanges(); return(CreatedAtAction(nameof(GetById), new { id = ride.RideId }, ride)); }
public List <Ride> GetAllRides() { var rideDto = new RideDTO(); SendRequest(new GetAllRidesRequest(rideDto)); var response = ReadResponse(); if (response is ErrorResponse) { throw new Exception("Error Get All Rides"); } return((response as GetRidesResponse)?.Rides.Select(DTOUtils.GetFromDto).ToList()); }
// POST: api/Rides public async Task PostAsync([FromBody] RideDTO ride) { Ride rideEntity = new Ride() { Rider = ride.Rider, RideTime = ride.Time, Porpoise = new Porpoise() { Name = ride.Porpoise.Name, Species = ride.Porpoise.Species } }; await _rideManagementService.AddRideAsync(rideEntity); }
public void Add(RideDTO r) { //solve possible duplicate data and errors //locations and cities will not be recreated when they already exist with the same properties List <Location> hulp = r.Stopovers.ToList(); foreach (Location l in r.Stopovers) { if (CityExists(l.City)) { _cities.Attach(l.City); } if (LocationExists(l)) { int index = hulp.IndexOf(l); hulp[index] = GetLocation(l); _locations.Attach(hulp[index]); } } Ride newR = new Ride(r.PickUpLocation, r.DropOffLocation, hulp, r.TravelDate, r.PassengerContribution, r.TotalAvailableSeats, _userRepository.GetById(r.Owner.id)); //solve possible duplicate data and errors //locations and cities will not be recreated when they already exist with the same properties if (CityExists(newR.PickUpLocation.City)) { _cities.Attach(newR.PickUpLocation.City); } if (CityExists(newR.DropOffLocation.City)) { _cities.Attach(newR.DropOffLocation.City); } if (LocationExists(newR.PickUpLocation)) { newR.PickUpLocation = GetLocation(newR.PickUpLocation); _locations.Attach(newR.PickUpLocation); } if (LocationExists(newR.DropOffLocation)) { newR.DropOffLocation = GetLocation(newR.DropOffLocation); _locations.Attach(newR.DropOffLocation); } _rides.Add(newR); }
public GetAllRidesRequest(RideDTO rideDto) { RideDto = rideDto; }
public async Task <RideDTO> EndRide(int rideId, RideDTO ride) { Ride rideEntity = await this.UnitOfWork.RideRepository.GetAsync(rideId); return(await this.EndRide(rideEntity, ride)); }
public async Task <RideDTO> EndRide(int rideId, RideDTO ride) { return(await this._service.EndRide(rideId, ride)); }