Пример #1
0
        public async Task <IActionResult> EndRide(int id, [FromBody] EndRideDto charge)
        {
            if (charge == null)
            {
                return(BadRequest("Missing body"));
            }

            var ride = await DbContext.Rides.FirstOrDefaultAsync(t => t.ID == id);

            if (ride == null)
            {
                return(NotFound("Ride with specified ID not found"));
            }

            await DbContext.EndRideAsync(id, charge.Charge);

            ride = await DbContext.Rides.FirstOrDefaultAsync(t => t.ID == id);

            return(Ok(ride));
        }