Working on using new data model
This commit is contained in:
50
view_index.go
Normal file
50
view_index.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type IndexVM struct {
|
||||
AssetCount int
|
||||
BrandCount int
|
||||
TotalRamCapacity int
|
||||
Brands []string
|
||||
Types []string
|
||||
}
|
||||
|
||||
func (a *App) getIndex(c *gin.Context) {
|
||||
vm := &IndexVM{}
|
||||
var err error
|
||||
vm.AssetCount, err = a.GetAssetCount()
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
|
||||
vm.BrandCount, err = a.GetBrandCount()
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
|
||||
vm.TotalRamCapacity, err = a.GetTotalRamCapacity()
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
|
||||
vm.Brands, err = a.GetAllBrands()
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
|
||||
vm.Types, err = a.GetAllTypes()
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.HTML(http.StatusOK, "index", vm)
|
||||
}
|
||||
Reference in New Issue
Block a user