aboutsummaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/router/items.go22
-rw-r--r--server/router/people.go11
2 files changed, 7 insertions, 26 deletions
diff --git a/server/router/items.go b/server/router/items.go
index 540fdf3..82f86ec 100644
--- a/server/router/items.go
+++ b/server/router/items.go
@@ -12,7 +12,7 @@ import (
"github.com/gin-gonic/gin"
"net/http"
- "strconv"
+ //"strconv"
db "github.com/MikunoNaka/openbills/database"
)
@@ -23,21 +23,7 @@ func getAllItems(ctx *gin.Context) {
}
func registerItem(ctx *gin.Context) {
- // extract data not string
- price, _ := strconv.ParseFloat(ctx.Query("price"), 64)
- gst, _ := strconv.ParseFloat(ctx.Query("gst"), 64)
- cat := "cat coming soon"
- brand := "brand coming soon"
-
- item := db.Item {
- Model: ctx.Query("model"),
- Description: ctx.Query("desc"),
- UnitPrice: price,
- HSN: ctx.Query("hsn"),
- TotalGST: gst,
- Category: cat,
- Brand: brand,
- }
-
- db.RegisterItem(item)
+ var newItem db.Item
+ ctx.Bind(&newItem)
+ db.RegisterItem(newItem)
}
diff --git a/server/router/people.go b/server/router/people.go
index bdb74a8..25d5353 100644
--- a/server/router/people.go
+++ b/server/router/people.go
@@ -22,12 +22,7 @@ func getAllPeople(ctx *gin.Context) {
}
func registerPerson(ctx *gin.Context) {
- person := db.Person {
- Name: ctx.Query("name"),
- Address: ctx.Query("address"),
- Phone: ctx.Query("phone"),
- Email: ctx.Query("email"),
- }
-
- db.RegisterPerson(person)
+ var newPerson db.Person
+ ctx.Bind(&newPerson)
+ db.RegisterPerson(newPerson)
}