public HttpResponseMessage endDrivertrip([FromBody] DriverTripsModel objDrivertripsModel) { var re = Request; var headers = re.Headers; if (headers.Contains("token")) { token = headers.GetValues("token").First(); } var result = Authtoken.checkToken(token); if (result == true) { objDrivertripsDL.insert_endttrip(objDrivertripsModel); var resp = Request.CreateResponse <ResponseModel>(HttpStatusCode.OK, new ResponseModel() { message = "your trip ended successfully", statuscode = Convert.ToInt16(HttpStatusCode.OK) }); return(resp); } else { var resp = Request.CreateResponse <ResponseModel>(HttpStatusCode.OK, new ResponseModel() { message = "UnAuthorized", statuscode = Convert.ToInt16(HttpStatusCode.OK), error = true }); return(resp); } }
public HttpResponseMessage createDrivertrip([FromBody] DriverTripsModel objDrivertripsModel) { var re = Request; var headers = re.Headers; if (headers.Contains("token")) { token = headers.GetValues("token").First(); } var result = Authtoken.checkToken(token); if (result == true) { dt.Columns.AddRange(new DataColumn[1] { new DataColumn("drivertripid", typeof(int)) }); int drivertripid = objDrivertripsDL.insert_starttrip(objDrivertripsModel); // dt.Columns.Add("drivertripid", typeof(System.Int16)); DataRow dr = dt.NewRow(); dr["drivertripid"] = drivertripid; // or dr[0]="Mohammad"; // or dr[1]=24; dt.Rows.Add(dr); var resp = Request.CreateResponse <ResponseModel>(HttpStatusCode.OK, new ResponseModel() { message = "your trip started successfully", output = dt, statuscode = Convert.ToInt16(HttpStatusCode.OK), error = false }); return(resp); } else { var resp = Request.CreateResponse <ResponseModel>(HttpStatusCode.OK, new ResponseModel() { message = "UnAuthorized", statuscode = Convert.ToInt16(HttpStatusCode.OK), error = true }); return(resp); } }
public int insert_endttrip(DriverTripsModel objdrivertripsModel) { try { return(Execution.ExecuteNonQuery_with_result("sp_drivertrips", new SqlParameter[] { new SqlParameter("@Command", "ENDTRIP"), new SqlParameter("@driverid", objdrivertripsModel.driverid), new SqlParameter("@driverTripId", objdrivertripsModel.drivertripid), new SqlParameter("@endLatitude", objdrivertripsModel.endlatitude), new SqlParameter("@endLongitude", objdrivertripsModel.endlongititude), new SqlParameter("@routeId", objdrivertripsModel.routeid), new SqlParameter("@tripstatus", 2), })); } catch (Exception ex) { throw ex; } }
public int insert_starttrip(DriverTripsModel objDrivertripsModel) { try { return(Execution.ExecuteNonQuery_with_result("sp_drivertrips", new SqlParameter[] { new SqlParameter("@Command", "STARTTRIP"), new SqlParameter("@driverid", objDrivertripsModel.driverid), new SqlParameter("@startLatitude", objDrivertripsModel.startlatitude), new SqlParameter("@startLongitude", objDrivertripsModel.startlongititude), new SqlParameter("@triptype", objDrivertripsModel.triptype), new SqlParameter("@tripstatus", 1), new SqlParameter("@status", 1), })); } catch (Exception ex) { throw ex; } }