public Scor findOne(int id) { MySqlConnection connection = databaseConnection.getConnection(); ParticipantRepository participantRepository = new ParticipantRepository(); ProbaRepository probaRepository = new ProbaRepository(); using (connection) { connection.Open(); MySqlCommand cmd = new MySqlCommand("Select * from scores where id=@id", connection); cmd.Parameters.AddWithValue("@id", id); cmd.Prepare(); using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { Participant participant = participantRepository.findOne(Convert.ToInt32(reader["id_participant"])); Proba proba = probaRepository.findOne(Convert.ToInt32(reader["id_proba"])); return(new Scor( Convert.ToInt32(reader["ID"]), participant, proba, Convert.ToInt32(reader["score"]) )); } } connection.Close(); } return(null); }
static void Main(string[] args) { BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider(); serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; BinaryClientFormatterSinkProvider clientProv = new BinaryClientFormatterSinkProvider(); IDictionary props = new Hashtable(); props["port"] = 55555; TcpChannel channel = new TcpChannel(props, clientProv, serverProv); ChannelServices.RegisterChannel(channel, false); IDictionary <string, string> pr = new SortedList <string, string>(); pr.Add("ConnectionString", "URI=file:ConcursInot.db"); OficiuRepository oficiu = new OficiuRepository(pr); ParticipantRepository participant = new ParticipantRepository(pr); ProbaRepository proba = new ProbaRepository(pr); InscriereRepository inscriere = new InscriereRepository(pr); Service service = new Service(oficiu, participant, proba, inscriere); var server = new ServerImplementation(service); RemotingServices.Marshal(server, "Server"); //RemotingConfiguration.RegisterWellKnownServiceType(typeof(ServerImplementation), "Server", // WellKnownObjectMode.Singleton); Console.WriteLine("Server started ..."); Console.WriteLine("Press <enter> to exit..."); Console.ReadLine(); }
public Service(OficiuRepository oficiuRepository, ParticipantRepository participantRepository, ProbaRepository probaRepository, InscriereRepository inscriereRepository) { this.oficiuRepository = oficiuRepository; this.participantRepository = participantRepository; this.probaRepository = probaRepository; this.inscriereRepository = inscriereRepository; }
/// <summary> /// Afiseaza probele in combobox /// </summary> public void fillProbeComboBox() { ProbaRepository probaRepository = new ProbaRepository(); ProbaService probaService = new ProbaService(probaRepository); probaController = new ProbaController(probaService); List <Proba> listaProbe = probaController.findAll(); foreach (Proba elem in listaProbe) { comboBoxProbe.DisplayMember = elem.Name; comboBoxProbe.ValueMember = elem.Id.ToString(); comboBoxProbe.Items.Add(elem); } }
public ProbaService(ProbaRepository probaRepository) { this.probaRepository = probaRepository; }