public VehiculoEN CrearVehiculo(VehiculoEN vehiculoCrear) { bool bPlacaExistente = false; bool bUsuarioTipoCliente = false; bPlacaExistente = VehiculoDAO.ValidarPlacaExistente(vehiculoCrear.Placa); UsuariosService usuarioProxy = new UsuariosService(); bUsuarioTipoCliente = usuarioProxy.ValidarUsuarioTipoCliente(vehiculoCrear.Usuario.Codigo); if (!bUsuarioTipoCliente) { throw new FaultException <RepetidoException>(new RepetidoException() { Codigo = 1, Mensaje = "Para registrar el vehiculo debe ser cliente, no administrador." }, new FaultReason("Validación de negocio")); } if (bPlacaExistente) { throw new FaultException <RepetidoException>(new RepetidoException() { Codigo = 2, Mensaje = "La placa ya ha sido registrada" }, new FaultReason("Validación de negocio")); } return(VehiculoDAO.Crear(vehiculoCrear)); }
public Vehiculo CrearVehiculo(int ID_VEHICULO, string PLACA, string MODELO, string MARCA, string ANNIO_FABRICACION, string NRO_UNIDAD, int id_empresa) { Empresa empresaExiste = EmpresaDAO.Obtener(id_empresa); Vehiculo VehiculoACrear = new Vehiculo() { //ID_VEHICULO = ID_VEHICULO, PLACA = PLACA, MODELO = MODELO, MARCA = MARCA, ANNIO_FABRICACION = ANNIO_FABRICACION, NRO_UNIDAD = NRO_UNIDAD, ID_EMPRESA = empresaExiste.ID_EMPRESA, }; return(VehiculoDAO.Crear(VehiculoACrear)); }