add product ingredients
This commit is contained in:
@@ -152,3 +152,27 @@ func UnitModelResponseToResponse(model *models.UnitResponse) contract.UnitRespon
|
||||
}
|
||||
}
|
||||
|
||||
func IngredientUnitsModelResponseToResponse(model *models.IngredientUnitsResponse) contract.IngredientUnitsResponse {
|
||||
if model == nil {
|
||||
return contract.IngredientUnitsResponse{}
|
||||
}
|
||||
|
||||
response := contract.IngredientUnitsResponse{
|
||||
IngredientID: model.IngredientID,
|
||||
IngredientName: model.IngredientName,
|
||||
BaseUnitID: model.BaseUnitID,
|
||||
BaseUnitName: model.BaseUnitName,
|
||||
Units: make([]*contract.UnitResponse, 0),
|
||||
}
|
||||
|
||||
// Map units
|
||||
for _, unit := range model.Units {
|
||||
if unit != nil {
|
||||
unitResp := UnitModelResponseToResponse(unit)
|
||||
response.Units = append(response.Units, &unitResp)
|
||||
}
|
||||
}
|
||||
|
||||
return response
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user