public bool EndTrip(TripEndDTO tripEndDTO, decimal distance) { var result = 0; if (currentTransaction == null) { connection = db.CreateConnection(); connection.Open(); } var transaction = (currentTransaction == null ? connection.BeginTransaction() : currentTransaction); try { var savecommand = db.GetStoredProcCommand(DBRoutine.TRIPEND); db.AddInParameter(savecommand, "TokenNo", System.Data.DbType.String, tripEndDTO.Token); db.AddInParameter(savecommand, "TripID", System.Data.DbType.String, tripEndDTO.TripID); db.AddInParameter(savecommand, "DriverID", System.Data.DbType.String, tripEndDTO.DriverID); db.AddInParameter(savecommand, "EndTime", System.Data.DbType.DateTime, tripEndDTO.EndTime); db.AddInParameter(savecommand, "TripEndLat", System.Data.DbType.Decimal, tripEndDTO.TripEndLat); db.AddInParameter(savecommand, "TripEndLong", System.Data.DbType.Decimal, tripEndDTO.TripEndLong); db.AddInParameter(savecommand, "DistanceTravelled", System.Data.DbType.Decimal, 0.00M); db.AddInParameter(savecommand, "Distance", System.Data.DbType.Decimal, distance); result = db.ExecuteNonQuery(savecommand, transaction); if (currentTransaction == null) { transaction.Commit(); } } catch (Exception ex) { if (currentTransaction == null) { transaction.Rollback(); } throw ex; } finally { transaction.Dispose(); connection.Close(); } return(result > 0 ? true : false); }
public IHttpActionResult EndTrip(TripEndDTO tripEndDTO) { try { var tripInfo = new TripBO().GetTrip(new Trip { TripID = tripEndDTO.TripID }); string frmLatLong = tripInfo.Latitude + "," + tripInfo.Longitude.ToString(); string toLatLong = tripEndDTO.TripEndLat + "," + tripEndDTO.TripEndLong.ToString(); decimal distance = GetTravelTimeBetweenTwoLocations(frmLatLong, toLatLong).distance; tripEndDTO.Token = HeaderValueByKey("AUTH_TOKEN"); tripEndDTO.DriverID = HeaderValueByKey("DRIVERID"); var result = new TripBO().EndTrip(tripEndDTO, distance); if (result) { tripInfo = new TripBO().GetTrip(new Trip { TripID = tripEndDTO.TripID }); var customerObj = new CustomerBO().GetCustomer(new Customer { MobileNo = tripInfo.CustomerMobile }); PushNotification(customerObj.DeviceID, "", UTILITY.NotifyTripEnd); return(Ok(new { tripID = tripEndDTO.TripID, message = UTILITY.SUCCESSMSG })); } else { return(BadRequest()); } } catch (Exception ex) { return(InternalServerError(ex)); } }
public bool EndTrip(TripEndDTO tripEndDTO, decimal distance) { return(tripDAL.EndTrip(tripEndDTO, distance)); }