Ejemplo n.º 1
0
        private CertificateSource CreateSourceForSupplier()
        {
            var source = CertificateSource.Queryable.FirstOrDefault(s => s.Suppliers.FirstOrDefault(certificateSupplier => certificateSupplier.Id == supplier.Id) != null);

            if (source == null)
            {
                using (new TransactionScope()) {
                    source = new CertificateSource {
                        SourceClassName = Path.GetRandomFileName()
                    };
                    source.Suppliers = new List <Supplier>();
                    source.Suppliers.Add(supplier);
                    source.Save();
                }
            }
            return(source);
        }
Ejemplo n.º 2
0
        public void SetUp()
        {
            var supplier     = TestSupplier.Create();
            var realSupplier = Supplier.Find(supplier.Id);

            using (new TransactionScope()) {
                var certificateSources = CertificateSource.Queryable.Where(s => s.SourceClassName == typeof(RostaCertificateSource).Name).ToList();
                certificateSources.ForEach(c => c.Delete());

                _source = new CertificateSource {
                    SourceClassName = typeof(RostaCertificateSource).Name
                };
                _source.Suppliers = new List <Supplier>();
                _source.Suppliers.Add(realSupplier);
                _source.Save();
            }
        }
        private CertificateSource CreateSourceForSupplier(Supplier supplier, string sourceClassName)
        {
            var source = new CertificateSource {
                SourceClassName = sourceClassName
            };

            var deletedSource = CertificateSource.Queryable.FirstOrDefault(s => s.SourceClassName == sourceClassName);

            if (deletedSource != null)
            {
                deletedSource.Delete();
            }

            source.Suppliers = new List <Supplier>();
            source.Suppliers.Add(supplier);
            source.Save();

            return(source);
        }