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); }
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; }
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}")); } }
public AutomovilModel UpdateAutomovil(int marcaId, int automovilId, AutomovilModel automovilModel) { GetAutomovil(marcaId, automovilId); automovilModel.Id = automovilId; return(new AutomovilModel(_libraryRepository.UpdateAutomovil(new AutomovilEntity(automovilModel)))); }
public AutomovilModel CreateAutomovil(int marcaId, AutomovilModel automovilModel) { validateMarca(marcaId); return(new AutomovilModel(_libraryRepository.CreateAutomovil(new AutomovilEntity(automovilModel)))); }
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}")); } }