Beispiel #1
0
        public override bool ProcessContract(ParticipantHandler participantHandler, List <Chain> chains)
        {
            if (ValidateContextual(participantHandler, chains))
            {
                var k = participantHandler.CountSimilarPatients(Country, Region, Birthyear);

                if (k < 3)
                {
                    throw new TransactionParkedException();
                }
                else
                {
                    participantHandler.AddPatient(new Patient()
                    {
                        Address = TransactionId
                        ,
                        Country = Country
                        ,
                        Region = Region
                        ,
                        Birthyear = Birthyear
                    });

                    return(true);
                }
            }

            return(false);
        }
        public bool ProcessContracts(ParticipantHandler participantHandler, List <Chain> context)
        {
            var ret = true;

            foreach (var t in TransactionList)
            {
                try
                {
                    ret &= t.ProcessContract(participantHandler, context);
                } catch (TransactionParkedException)
                {
                    ret &= true;

                    if (t.GetType() == typeof(PatientRegistrationTransaction))
                    {
                        var prt = (PatientRegistrationTransaction)t;

                        participantHandler.AddPatient(new Entities.Patient()
                        {
                            Address   = prt.TransactionId,
                            Country   = prt.Country,
                            Region    = prt.Region,
                            Birthyear = prt.Birthyear
                        });
                    }
                }
            }

            return(ret);
        }