public async Task <IActionResult> Post([FromBody] UserModels.Ride ride) { if (!ModelState.IsValid) { return(BadRequest()); } while (ride.Waypoints.Count < 3) { ride.Waypoints.Add(null); } var id = Guid.NewGuid().ToString(); var result = await MySqlDataAccess.Instance.Execute( "INSERT INTO oride.rides(Id, PolyLine, Bounds, Polygon, GoTime, ReturnTime, ScheduleType, Date," + "Days, SeatsAvail, Price, ContactNo, FromLatLng, ToLatLng, Way1LatLng, Way2LatLng, Way3LatLng, `From`," + "`To`, UserId, VehicleNo) VALUES(@p1, @p2, @p3, ST_GeomFromText(@p4), @p5, @p6, @p7, @p8, @p9, @p10, @p11," + "@p12, ST_GeomFromText(@p13), ST_GeomFromText(@p14), ST_GeomFromText(@p15), ST_GeomFromText(@p16), ST_GeomFromText(@p17)," + "@p18, @p19, @p20, @p21)", id, ride.PolyLine, ride.Bounds, ride.PolyGon, ride.StartTime, ride.ReturnTime, ride.ScheduleType, ride.Date, string.Join(',', ride.Days), ride.SeatsAvail, ride.Fare, ride.ContactNo, ride.From.LatLng, ride.To.LatLng, ride.Waypoints[0], ride.Waypoints[1], ride.Waypoints[2], ride.From.Name, ride.To.Name, uId, ride.Vehicle); if (result == 1) { return(Ok(id)); } return(StatusCode(500)); }
public async Task <IActionResult> Put([FromBody] UserModels.Ride ride) { var result = await MySqlDataAccess.Instance.Execute( "UPDATE oride.rides " + "set GoTime=@p1, ReturnTime=@p2, Date=@p3, Days=@p4, SeatsAvail=@p5, Price=@p6, Active=@p9 " + "WHERE id=@p7 and userid=@p8", ride.StartTime, ride.ReturnTime, ride.Date, string.Join(',', ride.Days), ride.SeatsAvail, ride.Fare, ride.Id, uId, ride.Active? 1 : 0); if (result == 1) { return(Ok()); } return(StatusCode(500)); }