public async Task <IActionResult> AddRides([FromBody] IEnumerable <RideDto> rides) { var userDto = await _userRepository.GetLoggedInUser(User); if (rides == null) { return(BadRequest("Invalid parameter")); } int count = 0; foreach (var ride in rides) { bool result = _rideLogic.AddRide(ride, userDto.Email); if (result) { count++; } else { break; } } if (count == rides.Count()) { return(Ok()); } else { return(BadRequest("Operation failed")); } }
public async Task <IActionResult> AddRides([FromBody] IEnumerable <RideDto> rides) { var userDto = await _userRepository.GetLoggedInUser(User); if (rides == null) { return(BadRequest()); } foreach (var ride in rides) { _rideLogic.AddRide(ride, userDto.Email); } return(Ok()); }