Exemplo n.º 1
0
        public IEnumerable <AutomovilModel> GetAutomoviles(int marcaId)
        {
            validateMarca(marcaId);
            var returnedList = _libraryRepository.GetAutomoviles(marcaId);
            var ans          = new List <AutomovilModel>();

            foreach (var item in returnedList)
            {
                var aux = new AutomovilModel(item);
                ans.Add(aux);
            }
            return(ans);
        }
Exemplo n.º 2
0
 public AutomovilEntity(AutomovilModel automovilModel)
 {
     this.Id               = automovilModel.Id;
     this.Propietario      = automovilModel.NombreCliente;
     this.Modelo           = automovilModel.Modelo;
     this.Color            = (ColorType)automovilModel.Color;
     this.NumeroDeAsientos = automovilModel.Asientos;
     this.VelocidadMaxima  = automovilModel.Velocidad;
     this.Precio           = automovilModel.Precio;
     this.Año              = automovilModel.Año;
     this.Kilometraje      = automovilModel.Kilometraje;
     this.Entregado        = automovilModel.Entregado;
     this.MarcaId          = automovilModel.Id;
 }
Exemplo n.º 3
0
 public ActionResult <AutomovilModel> CreateAutomovi(int marcaId, [FromBody] AutomovilModel automovil)
 {
     try
     {
         var automovilCreated = _automovilService.CreateAutomovil(marcaId, automovil);
         return(CreatedAtRoute("GetAutomovil", new { marcaId = marcaId, automovilId = automovilCreated.Id }, automovilCreated));
     }
     catch (NotFoundOperationException ex)
     {
         return(NotFound(ex.Message));
     }
     catch (Exception ex)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, $"Something happend: {ex.Message}"));
     }
 }
Exemplo n.º 4
0
 public AutomovilModel UpdateAutomovil(int marcaId, int automovilId, AutomovilModel automovilModel)
 {
     GetAutomovil(marcaId, automovilId);
     automovilModel.Id = automovilId;
     return(new AutomovilModel(_libraryRepository.UpdateAutomovil(new AutomovilEntity(automovilModel))));
 }
Exemplo n.º 5
0
 public AutomovilModel CreateAutomovil(int marcaId, AutomovilModel automovilModel)
 {
     validateMarca(marcaId);
     return(new AutomovilModel(_libraryRepository.CreateAutomovil(new AutomovilEntity(automovilModel))));
 }
Exemplo n.º 6
0
 public ActionResult <AutomovilModel> UpdateAutomovil(int marcaId, int automovilId, [FromBody] AutomovilModel automovilModel)
 {
     try
     {
         return(Ok(_automovilService.UpdateAutomovil(marcaId, automovilId, automovilModel)));
     }
     catch (NotFoundOperationException ex)
     {
         return(NotFound(ex.Message));
     }
     catch (Exception ex)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, $"Something happend: {ex.Message}"));
     }
 }