/// <summary> /// The main entry point for the application. /// </summary> //[STAThread] 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); string sqliteDBFileName = @System.Configuration.ConfigurationManager.AppSettings["jdbc.url"]; string log4netconfig = System.Configuration.ConfigurationManager.AppSettings["log4net.xmlconfig"]; IParticipantiRepository repoParticipanti = new RepositoryParticipanti(sqliteDBFileName, log4netconfig); IParticipariRepository repoParticipari = new RepositoryParticipari(sqliteDBFileName); IOrganizatoriRepository repoOrganizatori = new RepositoryOrganizatori(sqliteDBFileName, log4netconfig); IValidator <Participant> validator = new ValidatorParticipant(); var server = new Service(repoOrganizatori, repoParticipanti, repoParticipari, validator); RemotingServices.Marshal(server, "Server"); Console.WriteLine("Server started ..."); Console.ReadLine(); Console.WriteLine("Press <enter> to exit..."); }
public bool PutParticipant(participant participant) { try { if (ValidatorParticipant.IsParticipantExist(participant, GetAllParticipant()) && ValidatorParticipant.IsValide(participant)) { db.Entry(participant).State = EntityState.Modified; db.SaveChanges(); return(true); } else if (!ValidatorParticipant.IsParticipantExist(participant, GetAllParticipant())) { throw new ItemNotExistException("participant"); } else { throw new InvalidItemException("participant"); } } catch (Exception e) { throw e; } }
public bool PostParticipant(participant participant) { try { if (ValidatorParticipant.IsValide(participant) && !ValidatorParticipant.IsParticipantExist(participant, GetAllParticipant())) { db.participants.Add(participant); db.SaveChanges(); return(true); } else if (ValidatorParticipant.IsParticipantExist(participant, GetAllParticipant())) { throw new ExistingItemException("participant"); } else { throw new InvalidItemException("participant"); } } catch (Exception e) { throw e; } }