func (c *CardController) CardLeader(ctx *app.CardLeaderCardContext) error {
	dataStore := &dal.DataStore{}
	dataStore.GetSession()
	defer dataStore.Close()
	dc := dal.NewDalCard(dataStore)
	dg := dal.NewDalGroup(dataStore)
	group, errGroup := dg.FetchWithName("Leader")
	collectionCount, err := dc.CountLeader(group.ID)
	if helpers.IsNotFoundError(err) {
		return ctx.NotFound()
	}
	limit, offset := helpers.ValidateLimitOffset(collectionCount, ctx.Limit, ctx.Offset)
	cards, err := dc.FetchLeaderPaging(group.ID, limit, offset)
	if helpers.IsNotFoundError(err) {
		return ctx.NotFound()
	} else if err != nil || errGroup != nil {
		ctx.ResponseData.Service.LogError("InternalServerError", "req_id", middleware.ContextRequestID(ctx), "ctrl", "Card", "action", "CardLeader", ctx.RequestData.Request.Method, ctx.RequestData.Request.URL, "databaseError", err.Error())
		return ctx.InternalServerError()
	}
	res, lastModified, _ := factory.CreatePageCard(cards, "leaders", collectionCount, limit, offset, ctx.Lang)
	helpers.LastModified(ctx.ResponseData, lastModified)
	if ctx.IfModifiedSince != nil {
		if !helpers.IsModified(*ctx.IfModifiedSince, lastModified) {
			return ctx.NotModified()
		}
	}
	return ctx.OK(res)
}
CardLeader runs the cardLeader action.
package main
import (
	"github.com/GwentAPI/gwentapi/app"
	"github.com/GwentAPI/gwentapi/dataLayer/dal"
	"github.com/GwentAPI/gwentapi/dataLayer/factory"
	"github.com/GwentAPI/gwentapi/dataLayer/models"
	"github.com/GwentAPI/gwentapi/helpers"
	"github.com/goadesign/goa"
	"github.com/goadesign/goa/middleware"
)
type CardController struct {
	*goa.Controller
}
func NewCardController(service *goa.Service) *CardController {
	return &CardController{Controller: service.NewController("CardController")}
}
func (c *CardController) CardFaction(ctx *app.CardFactionCardContext) error {
	dataStore := &dal.DataStore{}
	dataStore.GetSession()
	defer dataStore.Close()
	dc := dal.NewDalCard(dataStore)
	df := dal.NewDalFaction(dataStore)
	factionUUID, errFactionUUID := helpers.DecodeUUID(ctx.FactionID)
	if errFactionUUID != nil {
		return ctx.NotFound()
	}
	faction, errFaction := df.Fetch(factionUUID)
	collectionCount, err := dc.CountFromFaction(faction.ID)
	if helpers.IsNotFoundError(errFaction) || helpers.IsNotFoundError(err) {
		return ctx.NotFound()
	}
	limit, offset := helpers.ValidateLimitOffset(collectionCount, ctx.Limit, ctx.Offset)
	cards, err := dc.FetchFromFactionPaging(faction.ID, limit, offset)
	if err != nil || errFaction != nil {
		ctx.ResponseData.Service.LogError("InternalServerError", "req_id", middleware.ContextRequestID(ctx), "ctrl", "Card", "action", "CardFaction", ctx.RequestData.Request.Method, ctx.RequestData.Request.URL, "databaseError", err.Error())
		return ctx.InternalServerError()
	}
	res, lastModified, _ := factory.CreatePageCard(cards, "factions/"+ctx.FactionID, collectionCount, limit, offset, ctx.Lang)
	helpers.LastModified(ctx.ResponseData, lastModified)
	if ctx.IfModifiedSince != nil {
		if !helpers.IsModified(*ctx.IfModifiedSince, lastModified) {
			return ctx.NotModified()
		}
	}
	return ctx.OK(res)
}
func (c *CardController) CardRarity(ctx *app.CardRarityCardContext) error {
	dataStore := &dal.DataStore{}
	dataStore.GetSession()
	defer dataStore.Close()
	dv := dal.NewDalVariation(dataStore)
	dr := dal.NewDalRarity(dataStore)
	rarityUUID, errRarityUUID := helpers.DecodeUUID(ctx.RarityID)
	if errRarityUUID != nil {
		return ctx.NotFound()
	}
	rarity, errRarity := dr.Fetch(rarityUUID)
	collectionCount, err := dv.CountFromRarity(rarity.ID)
	if helpers.IsNotFoundError(errRarity) || helpers.IsNotFoundError(err) {
		return ctx.NotFound()
	}
	limit, offset := helpers.ValidateLimitOffset(collectionCount, ctx.Limit, ctx.Offset)
	cardIDs, err := dv.FetchCardIDFromRarityPaging(rarity.ID, limit, offset)
	dc := dal.NewDalCard(dataStore)
	cards, errCard := dc.FetchFromArray(*cardIDs)
	if err != nil || errRarity != nil || errCard != nil {
		ctx.ResponseData.Service.LogError("InternalServerError", "req_id", middleware.ContextRequestID(ctx), "ctrl", "Card", "action", "CardRarity", ctx.RequestData.Request.Method, ctx.RequestData.Request.URL, "databaseError", err.Error())
		return ctx.InternalServerError()
	}
	res, lastModified, _ := factory.CreatePageCard(cards, "rarities/"+ctx.RarityID, collectionCount, limit, offset, ctx.Lang)
	helpers.LastModified(ctx.ResponseData, lastModified)
	if ctx.IfModifiedSince != nil {
		if !helpers.IsModified(*ctx.IfModifiedSince, lastModified) {
			return ctx.NotModified()
		}
	}
	return ctx.OK(res)
}