| @@ -1,5 +1,5 @@ | |||||
| // | // | ||||
| // Location.swift | |||||
| // cntrlFuel.swift | |||||
| // | // | ||||
| // | // | ||||
| // Created by Michiel Carman on 4/1/24. | // Created by Michiel Carman on 4/1/24. | ||||
| @@ -8,9 +8,9 @@ | |||||
| import Fluent | import Fluent | ||||
| import Vapor | import Vapor | ||||
| struct cntrlLocation: RouteCollection { | |||||
| struct cntrlFuel: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("locations") | |||||
| let rts = routes.grouped("fuels") | |||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | rts.put(use: update) | ||||
| @@ -19,18 +19,18 @@ struct cntrlLocation: RouteCollection { | |||||
| } | } | ||||
| } | } | ||||
| func index(req: Request) async throws -> [mdlLocation] { | |||||
| try await mdlLocation.query(on: req.db).all() | |||||
| func index(req: Request) async throws -> [mdlFuel] { | |||||
| try await mdlFuel.query(on: req.db).all() | |||||
| } | } | ||||
| func create(req: Request) async throws -> mdlLocation { | |||||
| let obj = try req.content.decode(mdlLocation.self) | |||||
| func create(req: Request) async throws -> mdlFuel { | |||||
| let obj = try req.content.decode(mdlFuel.self) | |||||
| try await obj.save(on: req.db) | try await obj.save(on: req.db) | ||||
| return obj | return obj | ||||
| } | } | ||||
| func update(req: Request) async throws -> mdlLocation{ | |||||
| let obj = try req.content.decode(mdlLocation.self) | |||||
| let dbobj = try await mdlLocation.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| func update(req: Request) async throws -> mdlFuel{ | |||||
| let obj = try req.content.decode(mdlFuel.self) | |||||
| let dbobj = try await mdlFuel.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | dbobj.updatedate = Date() | ||||
| dbobj.updateuserid = -1 | dbobj.updateuserid = -1 | ||||
| @@ -40,7 +40,7 @@ struct cntrlLocation: RouteCollection { | |||||
| } | } | ||||
| func delete(req: Request) async throws -> HTTPStatus { | func delete(req: Request) async throws -> HTTPStatus { | ||||
| guard let obj = try await mdlLocation.find(req.parameters.get("id"), on: req.db) else { | |||||
| guard let obj = try await mdlFuel.find(req.parameters.get("id"), on: req.db) else { | |||||
| throw Abort(.notFound) | throw Abort(.notFound) | ||||
| } | } | ||||
| try await obj.delete(on: req.db) | try await obj.delete(on: req.db) | ||||
| @@ -0,0 +1,8 @@ | |||||
| // | |||||
| // File 2.swift | |||||
| // | |||||
| // | |||||
| // Created by Michiel Carman on 4/2/24. | |||||
| // | |||||
| import Foundation | |||||
| @@ -0,0 +1,8 @@ | |||||
| // | |||||
| // File 2.swift | |||||
| // | |||||
| // | |||||
| // Created by Michiel Carman on 4/2/24. | |||||
| // | |||||
| import Foundation | |||||
| @@ -0,0 +1,8 @@ | |||||
| // | |||||
| // File 2.swift | |||||
| // | |||||
| // | |||||
| // Created by Michiel Carman on 4/2/24. | |||||
| // | |||||
| import Foundation | |||||
| @@ -0,0 +1,8 @@ | |||||
| // | |||||
| // File 2.swift | |||||
| // | |||||
| // | |||||
| // Created by Michiel Carman on 4/2/24. | |||||
| // | |||||
| import Foundation | |||||
| @@ -0,0 +1,8 @@ | |||||
| // | |||||
| // File 2.swift | |||||
| // | |||||
| // | |||||
| // Created by Michiel Carman on 4/2/24. | |||||
| // | |||||
| import Foundation | |||||
| @@ -0,0 +1,8 @@ | |||||
| // | |||||
| // File 2.swift | |||||
| // | |||||
| // | |||||
| // Created by Michiel Carman on 4/2/24. | |||||
| // | |||||
| import Foundation | |||||
| @@ -0,0 +1,8 @@ | |||||
| // | |||||
| // File 2.swift | |||||
| // | |||||
| // | |||||
| // Created by Michiel Carman on 4/2/24. | |||||
| // | |||||
| import Foundation | |||||
| @@ -0,0 +1,8 @@ | |||||
| // | |||||
| // File 2.swift | |||||
| // | |||||
| // | |||||
| // Created by Michiel Carman on 4/2/24. | |||||
| // | |||||
| import Foundation | |||||
| @@ -0,0 +1,8 @@ | |||||
| // | |||||
| // File 2.swift | |||||
| // | |||||
| // | |||||
| // Created by Michiel Carman on 4/2/24. | |||||
| // | |||||
| import Foundation | |||||
| @@ -0,0 +1,8 @@ | |||||
| // | |||||
| // File 2.swift | |||||
| // | |||||
| // | |||||
| // Created by Michiel Carman on 4/2/24. | |||||
| // | |||||
| import Foundation | |||||
| @@ -0,0 +1,8 @@ | |||||
| // | |||||
| // File 2.swift | |||||
| // | |||||
| // | |||||
| // Created by Michiel Carman on 4/2/24. | |||||
| // | |||||
| import Foundation | |||||
| @@ -0,0 +1,8 @@ | |||||
| // | |||||
| // File 2.swift | |||||
| // | |||||
| // | |||||
| // Created by Michiel Carman on 4/2/24. | |||||
| // | |||||
| import Foundation | |||||
| @@ -0,0 +1,8 @@ | |||||
| // | |||||
| // File 2.swift | |||||
| // | |||||
| // | |||||
| // Created by Michiel Carman on 4/2/24. | |||||
| // | |||||
| import Foundation | |||||
| @@ -0,0 +1,8 @@ | |||||
| // | |||||
| // File 2.swift | |||||
| // | |||||
| // | |||||
| // Created by Michiel Carman on 4/2/24. | |||||
| // | |||||
| import Foundation | |||||
| @@ -0,0 +1,8 @@ | |||||
| // | |||||
| // File 2.swift | |||||
| // | |||||
| // | |||||
| // Created by Michiel Carman on 4/2/24. | |||||
| // | |||||
| import Foundation | |||||
| @@ -0,0 +1,8 @@ | |||||
| // | |||||
| // File.swift | |||||
| // | |||||
| // | |||||
| // Created by Michiel Carman on 4/2/24. | |||||
| // | |||||
| import Foundation | |||||
| @@ -0,0 +1,8 @@ | |||||
| // | |||||
| // File.swift | |||||
| // | |||||
| // | |||||
| // Created by Michiel Carman on 4/2/24. | |||||
| // | |||||
| import Foundation | |||||
| @@ -0,0 +1,8 @@ | |||||
| // | |||||
| // File 2.swift | |||||
| // | |||||
| // | |||||
| // Created by Michiel Carman on 4/2/24. | |||||
| // | |||||
| import Foundation | |||||
| @@ -0,0 +1,8 @@ | |||||
| // | |||||
| // File 3.swift | |||||
| // | |||||
| // | |||||
| // Created by Michiel Carman on 4/2/24. | |||||
| // | |||||
| import Foundation | |||||
| @@ -0,0 +1,8 @@ | |||||
| // | |||||
| // File 4.swift | |||||
| // | |||||
| // | |||||
| // Created by Michiel Carman on 4/2/24. | |||||
| // | |||||
| import Foundation | |||||
| @@ -0,0 +1,8 @@ | |||||
| // | |||||
| // File 5.swift | |||||
| // | |||||
| // | |||||
| // Created by Michiel Carman on 4/2/24. | |||||
| // | |||||
| import Foundation | |||||
| @@ -0,0 +1,8 @@ | |||||
| // | |||||
| // File 7.swift | |||||
| // | |||||
| // | |||||
| // Created by Michiel Carman on 4/2/24. | |||||
| // | |||||
| import Foundation | |||||
| @@ -0,0 +1,8 @@ | |||||
| // | |||||
| // File.swift | |||||
| // | |||||
| // | |||||
| // Created by Michiel Carman on 4/2/24. | |||||
| // | |||||
| import Foundation | |||||