Private
Public Access
27 lines
525 B
Go
27 lines
525 B
Go
package repuestos
|
|
|
|
import (
|
|
"net/http"
|
|
"repuestera_back/models"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
r "repuestera_back/repositorios"
|
|
)
|
|
|
|
|
|
|
|
func CrearRepuesto(c *gin.Context){
|
|
var repuesto *models.Repuesto
|
|
if err := c.ShouldBindJSON(&repuesto); err != nil {
|
|
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
|
return
|
|
}
|
|
|
|
if err := r.ObtenerRepositorios().Repuesto.Crear(repuesto); err != nil {
|
|
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
|
return
|
|
}
|
|
c.JSON(http.StatusCreated, repuesto)
|
|
}
|