Inheritance: DbContext
        public void Performance_test()
        {
            const int MessageCount = 100;

            var context = new MyContext();

            Scenario.Define(context)
                .WithEndpoint<ExternalIntegrationsManagementEndpoint>(b => b.Given((bus, c) => Subscriptions.OnEndpointSubscribed(s =>
                {
                    if (s.SubscriberReturnAddress.Queue.Contains("ExternalProcessor"))
                    {
                        c.ExternalProcessorSubscribed = true;
                    }
                })).AppConfig(PathToAppConfig))
                .WithEndpoint<FailingReceiver>(b => b.When(c => c.ExternalProcessorSubscribed, bus =>
                {
                    for (var i = 0; i < MessageCount; i++)
                    {
                        bus.SendLocal(new MyMessage { Body = i.ToString() });
                    }
                }))
                .WithEndpoint<ExternalProcessor>(b => b.Given((bus, c) => bus.Subscribe<MessageFailed>()))
                .Done(c => c.LastEventDeliveredAt.HasValue && c.LastEventDeliveredAt.Value.Add(TimeSpan.FromSeconds(10)) < DateTime.Now) //Wait 10 seconds from last event
                .Run();

            Console.WriteLine("Delivered {0} messages", context.EventsDelivered.Count);
        }
Exemple #2
0
        public void it_should_map_a_foreign_key()
        {
            var ctx = new MyContext();

            ctx.Categories.ToList();
            ctx.Products.ToList();
        }
        public void Should_be_reflected_as_active_endpoints_in_the_heartbeat_summary()
        {
            var context = new MyContext();

            HeartbeatSummary summary = null;

            Scenario.Define(context)
                .WithEndpoint<ManagementEndpoint>(c => c.AppConfig(PathToAppConfig))
                .WithEndpoint<Endpoint1>()
                .WithEndpoint<Endpoint2>()
                .Done(c =>
                    {
                        if (!TryGet("/api/heartbeats/stats", out summary, m => m.Active >= 2))
                        {
                            return false;
                        }

                        List<EndpointsView> endpoints;

                        return TryGetMany("/api/endpoints", out endpoints, e => e.Name.Contains("Endpoint1") );

                    })
                .Run(TimeSpan.FromMinutes(2));


            Assert.AreEqual(0, summary.Failing);
        }
		public void SetException ()
		{
			var context = new MyContext ();
			try {
				SynchronizationContext.SetSynchronizationContext (context);
				var awaiter = AsyncVoidMethodBuilder.Create ();

				Assert.AreEqual (1, context.Started, "#1");
				Assert.AreEqual (0, context.Completed, "#2");
				Assert.AreEqual (0, context.SendCounter, "#3");
				Assert.AreEqual (0, context.PostCounter, "#4");

				awaiter.SetException (new ApplicationException ());

				Assert.AreEqual (1, context.Started, "#5");
				Assert.AreEqual (1, context.Completed, "#6");
				Assert.AreEqual (0, context.SendCounter, "#7");
				Assert.AreEqual (1, context.PostCounter, "#8");

				awaiter.SetResult ();

				Assert.AreEqual (1, context.Started, "#9");
				Assert.AreEqual (2, context.Completed, "#10");
				Assert.AreEqual (0, context.SendCounter, "#11");
				Assert.AreEqual (1, context.PostCounter, "#12");
			} finally {
				SynchronizationContext.SetSynchronizationContext (null);
			}
		}
Exemple #5
0
        public void it_should_add_a_category_and_products()
        {
            var ctx = new MyContext();

            ctx.Categories.AddOrUpdate(x => x.Name ,new Category
                {
                    Name = "Electronics",
                    CategoryId = Guid.NewGuid()
                });

            ctx.SaveChanges();

            var category = ctx.Categories.First(x => x.Name.Equals("Electronics"));

            ctx.Products.Add(new Product
                {
                    Category = category,
                    Name = "Play Station 3",
                    ProductId = Guid.NewGuid()
                });
            ctx.Products.Add(new Product
                {
                    Category = category,
                    Name = "XBox 360",
                    ProductId = Guid.NewGuid()
                });

            ctx.SaveChanges();
        }
Exemple #6
0
	public static int Main ()
	{
		var mre = new ManualResetEvent (false);
		await_mre = new ManualResetEvent (false);
		var context = new MyContext (mre);
		try {
			SynchronizationContext.SetSynchronizationContext (context);
			var t = Test ();
			await_mre.Set ();
			if (!t.Wait (3000))
				return 3;
				
			// Wait is needed because synchronization is executed as continuation (once task finished)
			if (!mre.WaitOne (3000))
				return 2;
		} finally {
			SynchronizationContext.SetSynchronizationContext (null);
		}

		if (context.Started != 0 || context.Completed != 0 || context.SendCounter != 0)
			return 1;

		Console.WriteLine ("ok");
		return 0;
	}
        public static void Column_names_are_configured_correctly()
        {
            using (var context = new MyContext())
            {
                var objectContext = ((IObjectContextAdapter)context).ObjectContext;

                var modelEntityTypes = objectContext.MetadataWorkspace.GetItems<EntityType>(DataSpace.CSpace);
                Assert.Equal(1, modelEntityTypes.Count);
                Assert.Equal(6, modelEntityTypes[0].Properties.Count);

                var storeEntityTypes = objectContext.MetadataWorkspace.GetItems<EntityType>(DataSpace.SSpace);
                Assert.Equal(3, storeEntityTypes.Count);

                Assert.Equal(4, storeEntityTypes[0].Properties.Count);
                Assert.Equal("Key1", storeEntityTypes[0].Properties[0].Name);
                Assert.Equal("Key2A", storeEntityTypes[0].Properties[1].Name);
                Assert.Equal("Key3B", storeEntityTypes[0].Properties[2].Name);
                Assert.Equal("Column1", storeEntityTypes[0].Properties[3].Name);

                Assert.Equal(4, storeEntityTypes[1].Properties.Count);
                Assert.Equal("T2Key1", storeEntityTypes[1].Properties[0].Name);
                Assert.Equal("T2Key2", storeEntityTypes[1].Properties[1].Name);
                Assert.Equal("T2Key3", storeEntityTypes[1].Properties[2].Name);
                Assert.Equal("Column2", storeEntityTypes[1].Properties[3].Name);

                Assert.Equal(4, storeEntityTypes[2].Properties.Count);
                Assert.Equal("T3Key1", storeEntityTypes[2].Properties[0].Name);
                Assert.Equal("Key2A", storeEntityTypes[2].Properties[1].Name);
                Assert.Equal("Key3B", storeEntityTypes[2].Properties[2].Name);
                Assert.Equal("T3Column3", storeEntityTypes[2].Properties[3].Name);
            }
        }
        public void Notification_should_be_published_on_the_bus()
        {
            var context = new MyContext();

            Scenario.Define(context)
                .WithEndpoint<ExternalIntegrationsManagementEndpoint>(b => b.Given((bus, c) => Subscriptions.OnEndpointSubscribed(s =>
                {
                    if (s.SubscriberReturnAddress.Queue.Contains("ExternalProcessor"))
                    {
                        c.ExternalProcessorSubscribed = true;
                    }
                })).AppConfig(PathToAppConfig))
                .WithEndpoint<FailingReceiver>(b => b.When(c => c.ExternalProcessorSubscribed, bus => bus.SendLocal(new MyMessage { Body = "Faulty message" })))
                .WithEndpoint<ExternalProcessor>(b => b.Given((bus, c) => bus.Subscribe<HeartbeatStopped>()))
                .Done(c => c.EventsDelivered.Count >= 1)
                .Run();

            var deserializedEvent = JsonConvert.DeserializeObject<MessageFailed>(context.EventsDelivered[0]);

            Assert.AreEqual("Faulty message", deserializedEvent.FailureDetails.Exception.Message);
            //These are important so check it they are set
            Assert.IsNotNull(deserializedEvent.MessageDetails.MessageId);
            Assert.IsNotNull(deserializedEvent.SendingEndpoint.Name);
            Assert.IsNotNull(deserializedEvent.ProcessingEndpoint.Name);
        }
            public void Generated_SQL_for_query_with_nested_FirstOrDefault_in_subquery_honors_OrderBy()
            {
                using (var context = new MyContext())
                {
                    var query =
                        from a in context.As
                        select new
                        {
                            A = a,
                            B = a.Bs.OrderBy(b => b.P1).FirstOrDefault(b => b.P2 == "")
                        };

                    QueryTestHelpers.VerifyQuery(
                        query,
@"SELECT 
    [Extent1].[Id] AS [Id], 
    [Limit1].[Id] AS [Id1], 
    [Limit1].[P1] AS [P1], 
    [Limit1].[P2] AS [P2], 
    [Limit1].[A_Id] AS [A_Id]
    FROM  [dbo].[A] AS [Extent1]
    OUTER APPLY  (SELECT TOP (1) [Project1].[Id] AS [Id], [Project1].[P1] AS [P1], [Project1].[P2] AS [P2], [Project1].[A_Id] AS [A_Id]
        FROM ( SELECT 
            [Extent2].[Id] AS [Id], 
            [Extent2].[P1] AS [P1], 
            [Extent2].[P2] AS [P2], 
            [Extent2].[A_Id] AS [A_Id]
            FROM [dbo].[B] AS [Extent2]
            WHERE ([Extent1].[Id] = [Extent2].[A_Id]) AND (N'' = [Extent2].[P2])
        )  AS [Project1]
        ORDER BY [Project1].[P1] ASC ) AS [Limit1]");
                }
            }
            public void Generated_SQL_for_query_with_nested_FirstOrDefault_in_filter_honors_OrderBy()
            {
                using (var context = new MyContext())
                {
                    var query =
                        from a in context.As
                        where
                            a.Id == 1
                            && a.Bs.OrderBy(b => b.P1).FirstOrDefault(b => b.P2 == "") != null
                        select a;

                    QueryTestHelpers.VerifyQuery(
                        query,
@"SELECT 
    [Extent1].[Id] AS [Id]
    FROM  [dbo].[A] AS [Extent1]
    CROSS APPLY  (SELECT TOP (1) [Project1].[Id] AS [Id]
        FROM ( SELECT 
            [Extent2].[Id] AS [Id], 
            [Extent2].[P1] AS [P1]
            FROM [dbo].[B] AS [Extent2]
            WHERE ([Extent1].[Id] = [Extent2].[A_Id]) AND (N'' = [Extent2].[P2])
        )  AS [Project1]
        ORDER BY [Project1].[P1] ASC ) AS [Limit1]
    WHERE (1 = [Extent1].[Id]) AND ([Limit1].[Id] IS NOT NULL)");
                }               
            }
        public void Should_show_up_as_resolved_when_doing_a_single_retry()
        {
            FailedMessage failure = null;

            var context = new MyContext();

            Scenario.Define(context)
                .WithEndpoint<ManagementEndpoint>(c => c.AppConfig(PathToAppConfig))
                .WithEndpoint<FailureEndpoint>(b => b.Given((bus, c) =>
                {
                    c.EndpointNameOfReceivingEndpoint = Configure.EndpointName;
                    c.MessageId = Guid.NewGuid().ToString();
                    c.UniqueMessageId = DeterministicGuid.MakeId(c.MessageId, c.EndpointNameOfReceivingEndpoint).ToString();
                }))
                .Done(c =>
                {
                    if (!c.RetryIssued && GetFailedMessage(c, out failure))
                    {
                        IssueRetry(c, () => Post<object>(String.Format("/api/errors/{0}/retry", c.UniqueMessageId)));

                        return false;
                    }

                    return c.Done && GetFailedMessage(c, out failure, x => x.Status == FailedMessageStatus.RetryIssued);
                })
                .Run(TimeSpan.FromMinutes(2));

            Assert.AreEqual(FailedMessageStatus.RetryIssued, failure.Status);
        }
        public void Notification_is_published_on_a_bus()
        {
            var context = new MyContext();

            Scenario.Define(context)
                .WithEndpoint<ExternalIntegrationsManagementEndpoint>(b => b.Given((bus, c) => Subscriptions.OnEndpointSubscribed(s =>
                {
                    if (s.SubscriberReturnAddress.Queue.Contains("ExternalProcessor"))
                    {
                        c.ExternalProcessorSubscribed = true;
                    }
                })).When(c => c.ExternalProcessorSubscribed, bus => bus.Publish(new EndpointFailedToHeartbeat
                {
                    DetectedAt = new DateTime(2013,09,13,13,14,13),
                    LastReceivedAt = new DateTime(2013, 09, 13, 13, 13, 13),
                    Endpoint = new EndpointDetails
                    {
                        Host = "UnluckyHost",
                        HostId = Guid.NewGuid(),
                        Name = "UnluckyEndpoint"
                    }

                })).AppConfig(PathToAppConfig))
                .WithEndpoint<ExternalProcessor>(b => b.Given((bus, c) => bus.Subscribe<HeartbeatStopped>()))
                .Done(c => c.NotificationDelivered)
                .Run();

            Assert.IsTrue(context.NotificationDelivered);
        }
 public override object Evaluate(MyContext context)
 {
     context.AddLog("> ");
     object o = DoStatement(context);
     context.AddLog(";");
     return o;
 }
 public void Verify_that_models_with_more_than_UseSortedListCrossover_entities_work_fine()
 {
     using (var ctx = new MyContext())
     {
         ctx.MyEntities_01.Add(new MyEntity_01());
     }
 }
        public void It_enforces_foreign_key(bool suppress)
        {
            var options = new DbContextOptionsBuilder()
                .UseSqlite(_testStore.ConnectionString,
                    b =>
                        {
                            if (suppress)
                            {
                                b.SuppressForeignKeyEnforcement();
                            }
                        }).Options;

            using (var context = new MyContext(options))
            {
                context.Database.EnsureCreated();
                context.Add(new Child { ParentId = 4 });
                if (suppress)
                {
                    context.SaveChanges();
                }
                else
                {
                    var ex = Assert.Throws<DbUpdateException>(() => { context.SaveChanges(); });
                    Assert.Contains("FOREIGN KEY constraint failed", ex.InnerException.Message, StringComparison.OrdinalIgnoreCase);
                }
            }
        }
 /// <summary>
 /// Fetches the User entity from the database.
 /// </summary>
 private User FetchUserFromDatabase(MyContext dc, int id)
 {
     var user = dc.Users
         .Include(u => u.Books)
         .Include(u => u.FavoriteGenres)
         .Single(u => u.Id == id);
     return user;
 }
Exemple #17
0
 static void Main(string[] args)
 {
     Database.SetInitializer(new MigrateDatabaseToLatestVersion<MyContext, Configuration>());
     using (var context = new MyContext())
     {
         lazyLoadingAndDynamicProxies(context);
     }
 }
 bool GetFailedMessage(MyContext c, out FailedMessage failure, Predicate<FailedMessage> condition = null)
 {
     if (!TryGet("/api/errors/" + c.UniqueMessageId, out failure, condition))
     {
         return false;
     }
     return true;
 }
        public MainViewModel()
        {
            ShowAddVraagCommand = new RelayCommand(ShowAddVraag);
            SaveVraagCommand = new RelayCommand(SaveVraag);
            DellVraagCommand = new RelayCommand(DellVraag);
            DellAntwoordCommand = new RelayCommand(DellAntwoord);
            DellVraagFromQuizCommand = new RelayCommand(DellVraagFromQuiz);
            DellQuizCommand = new RelayCommand(DellQuiz);
            eersteAntwoord = new RelayCommand(EersteAntwoord,CanEersteAntwoord);
            tweedeAntwoord = new RelayCommand(TweedeAntwoord,CanTweedeAntwoord);
            derdeAntwoord = new RelayCommand(DerdeAntwoord,CanDerdeAntwoord);
            vierdeAntwoord = new RelayCommand(VierdeAntwoord,CanVierdeAntwoord);
            ShowAddAntwoordCommand = new RelayCommand(ShowAddAntwoord);
            SaveAntwoordCommand = new RelayCommand(SaveAntwoord);
            AddVraagToQuizCommand = new RelayCommand(AddVraagToQuiz);
            QuizWindowCommand = new RelayCommand(ShowQuizWindow);
            AddQuizWindowCommand = new RelayCommand(ShowAddQuiz);
            AddQuizCommand = new RelayCommand(SaveQuiz);
            PlayCommand = new RelayCommand(PlayGame);
            SelectedQuiz = new QuizVM( context);
            SelectedVraag = new VragenVM(context);
            SelectedCategorie = new VraagCategorienVM();
            currentVraag = new Vraag();
            gameAntwoorden = new AntwoordenVM[10];
            totaalPunten = 0;

            context = new MyContext();

            //1. ophalen vragen
            IEnumerable<VragenVM> vragen = context.Vragen
                .ToList().Select(g => new VragenVM(g, context));
            Vragen = new ObservableCollection<VragenVM>(vragen);

            //Categorie vragen ophalen

            if (context.VraagCategorie.Count()== 0)
            {
                context.VraagCategorie.Add(new VraagCategorie() { Id = 1, Name = "Taal" });
                context.VraagCategorie.Add(new VraagCategorie() { Id = 2, Name = "Scheikunde" });
                context.VraagCategorie.Add(new VraagCategorie() { Id = 3, Name = "Wiskunde" });
                context.VraagCategorie.Add(new VraagCategorie() { Id = 4, Name = "Techniek" });
                context.VraagCategorie.Add(new VraagCategorie() { Id = 5, Name = "bier" });
                context.SaveChanges();
            }

            IEnumerable<VraagCategorienVM> categorie = context.VraagCategorie.ToList().Select(c => new VraagCategorienVM(c));
            Categorie = new ObservableCollection<VraagCategorienVM>(categorie);

            // Quizen ophalen
            IEnumerable<QuizVM> quiz = context.Quizen.ToList().Select(c => new QuizVM(c, context));
            Quizen = new ObservableCollection<QuizVM>(quiz);

            //Antwoorden bij de vragen ophalen
            IEnumerable<AntwoordenVM> antwoorden = context.Antwoorden.ToList().Select(a => new AntwoordenVM(a,context));
            Antwoorden = new ObservableCollection<AntwoordenVM>(antwoorden);
            vraagAntwoorden = Antwoorden.Where(a => a.BijVraagId.Equals(_selectedVraag.Id));
            VraagAntwoorden = new ObservableCollection<AntwoordenVM>(vraagAntwoorden);
        }
Exemple #20
0
        public MainViewModel()
        {
            MyContext container = new MyContext();
            Competition comp = container.Competitions.Include("Teams").First();

            //Competition = new CompetitionVM();

               Competition = new CompetitionVM(comp);
        }
Exemple #21
0
        public static void ShowTeacher()
        {
            lc = new List<Lecture>
            {
                new Lecture
                {
                    Name = "Lecture 1",
                    Category=".Net",
                    Discriptions="OOP"
                },
                new Lecture
                {
                    Name = "Lecture 2",
                    Category="JS",
                    Discriptions="HTML5"
                },
                new Lecture
                {
                    Name = "Lecture 3",
                    Category="PHP",
                    Discriptions="HTML"
                },
            };
            using (var db = new MyContext())
            {
                var tc = new List<Teacher>
                {
                    new Teacher
                    {
                        Name = "Ivan Filatov",
                        Lecture = lc
                    },
                    new Teacher
                    {
                        Name = "Roman Sokolov",
                        Lecture = lc
                    },
                    new Teacher
                    {
                        Name = "Roman Sergeev",
                        Lecture = lc
                    }
                };

                db.teachers.AddRange(tc);
                db.SaveChanges();
                Console.WriteLine("Rating teachers on the number of lectures");
                //var lectures = db.lect.Select(item => item).ToList();
                //var teachers = db.teachers.Select((item => item)).ToList();
                var result = db.teachers.Select(item => new { Teacher = item.Name, LectureCount = item.Lecture.Count() });
                foreach (var tst in result)
                {
                    Console.WriteLine(tst);
                }
            }
        }
Exemple #22
0
        // Test class constructor
        public AccountTests()
        {
            // Create fake service
            fakeContext = new XrmFakedContext();
            fakeService = fakeContext.GetOrganizationService();

            // Create real service
            realContext = new MyContext("XRM");
            realService = realContext.GetOrganizationService();
        }
Exemple #23
0
        private static void lazyLoadingAndDynamicProxies(MyContext context)
        {
            var user = context.UserProfiles.Find(1);
            if (user == null)
                return;

            var lazyLoadedDocs = user.Docs;
            // To view its implementation, right click on the method and then select `go to implementation`
            var rpt = DocsPdfReport.CreatePdfReport(lazyLoadedDocs);
            Process.Start(rpt.FileName);
        }
Exemple #24
0
        public void Start()
        {
            using (var db = new MyContext())
            {
                db.Database.Initialize(true);

                var article = new Article {Title = "Muj prvni clanek"};
                db.Articles.Add(article);
                db.SaveChanges();
            }
        }
        public override object Evaluate(MyContext context)
        {
            var p = context.GetProgramDeclNode(Name);

            foreach (var func in p.Funcs)
            {
                func.Evaluate(context);
            }

            var o = p.Statements.Evaluate(context);
            return o;
        }
        void IssueRetry(MyContext c, Action retryAction)
        {
            if (c.RetryIssued)
            {
                Thread.Sleep(1000); //todo: add support for a "default" delay when Done() returns false
            }
            else
            {
                c.RetryIssued = true;

                retryAction();
            }
        }
        public void Should_result_in_a_startup_event()
        {
            var context = new MyContext();

            EventLogItem entry = null;

            Scenario.Define(context)
                .WithEndpoint<ManagementEndpoint>(c => c.AppConfig(PathToAppConfig))
                .WithEndpoint<StartingEndpoint>()
                .Done(c => TryGetSingle("/api/eventlogitems/", out entry, e => e.RelatedTo.Any(r => r.Contains(typeof(StartingEndpoint).Name)) && e.EventType == typeof(EndpointStarted).Name))
                .Run();

            Assert.AreEqual(Severity.Info, entry.Severity, "Endpoint startup should be treated as info");
            Assert.IsTrue(entry.RelatedTo.Any(item => item == "/host/" + context.HostId));           
        }
        public void Should_result_in_a_custom_check_failed_event()
        {
            var context = new MyContext();

            EventLogItem entry = null;

            Scenario.Define(context)
                .WithEndpoint<ManagementEndpoint>(c => c.AppConfig(PathToAppConfig))
                .WithEndpoint<EndpointWithFailingCustomCheck>()
                .Done(c => TryGetSingle("/api/eventlogitems/", out entry, e => e.EventType == typeof(CustomCheckFailed).Name))
                .Run();

            Assert.AreEqual(Severity.Error, entry.Severity, "Failed custom checks should be treated as error");
            Assert.IsTrue(entry.RelatedTo.Any(item => item == "/customcheck/EventuallyFailingCustomCheck"));
        }
Exemple #29
0
 public static void Seed(MyContext context)
 {
     context.Customers.AddOrUpdate(customer => customer.FirstName,
         new Customer
         {
             FirstName = "Justin",
             LastName = "Obney",
             Address = new Address
             {
                 Street = "123 Street",
                 City = "Baton Rouge",
                 State = "LA"
             }
         });
 }
Exemple #30
0
        public void it_should_update_a_category()
        {
            var ctx = new MyContext();
            Category category;

            category = ctx.Categories.First(x => x.Name.Equals("Electronics"));
            category.Name = "Electronics1";
            ctx.SaveChanges();

            category = ctx.Categories.First(x => x.Name.Equals("Electronics1"));
            category.Name = "Electronics";
            ctx.SaveChanges();

            category = ctx.Categories.First(x => x.Name.Equals("Electronics"));
        }
 public MovementsProviderepository(MyContext context)
     : base(context)
 {
 }
 public CategoriesController(MyContext context)
 {
     database = context;
 }
 public StockRepository(MyContext myContext, IPropertyMappingContainer propertyMappingContainer)
 {
     _myContext = myContext;
     _propertyMappingContainer = propertyMappingContainer;
 }
 public KomentarHub(MyContext context)
 {
     _ctx = context;
 }
 public APSchemaRWAuth(MyContext db)
 {
     Query    = new APQueryAuth(db);
     Mutation = new APMutatorAuth(db);
 }
Exemple #36
0
 public UplateRepository(MyContext context)
 {
     this.context = context;
 }
 public InscriptionFinalController(MyContext context, IMapper mapper)
 {
     this.context = context;
     this._mapper = mapper;
 }
Exemple #38
0
 public HomeController(MyContext context)
 {
     _context = context;
 }
Exemple #39
0
 public SkladnikController(MyContext context)
 {
     _context = context;
 }
Exemple #40
0
 public RepositoryBase(IDataBaseFactory Factory)
 {
     ctx   = Factory.DataContext;
     DbSet = ctx.Set <T>();
 }
Exemple #41
0
 public DataBaseFactory()
 {
     dataContext = new MyContext();
 }
Exemple #42
0
 public HomeController(MyContext context)
 {
     this.context = context;
     sneakers     = this.context.Sneakers.ToList();
     brands       = this.context.Brands.ToList();
 }
Exemple #43
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, MyContext db)
        {
            #region Миграция

            try
            {
                if (!db.Database.EnsureCreated())
                {
                    db.Database.Migrate();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }


            #endregion


            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();


            app.Use(async(context, next) =>
            {
                await next();

                if (context.Response.StatusCode == 404 &&
                    !Path.HasExtension(context.Request.Path.Value) &&
                    !context.Request.Path.Value.StartsWith("/api/"))
                {
                    context.Request.Path = "/index.html";
                    await next();
                }
            });

            app.UseStaticFiles();

            //app.UseMvcWithDefaultRoute();
            //app.UseDefaultFiles();
            //app.UseStaticFiles();


            app.UseMvc();
        }
Exemple #44
0
 public UnitOfWork()
 {
     _context = new MyContext();
 }
 public RolesController(MyContext context)
 {
     _context = context;
 }
 public GhostController(MyContext context)
 {
     _context = context;
 }
 public OrderLineRepository(MyContext db)
 {
     _db = db;
 }
Exemple #48
0
 public ActivityController(MyContext context)
 {
     dbContext = context;
 }
Exemple #49
0
 public SanPhamF()
 {
     context = new MyContext();
 }
 public ProductService(MyContext myContext)
 {
     this.myContext = myContext;
 }
 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
 /// <summary>
 /// 用来具体指定如何处理每个http请求
 /// </summary>
 /// <param name="app"></param>
 /// <param name="env"></param>
 public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, MyContext myContext)//参数app、env都是已经注入的services
 {
     //loggerFactory.AddProvider(new NLogLoggerProvider());
     loggerFactory.AddNLog();//添加NLog日志服务
     if (env.IsDevelopment())
     {
         app.UseDeveloperExceptionPage();//在Development环境下调用异常处理程序
     }
     else
     {
         app.UseExceptionHandler();        //异常处理中间件
     }
     myContext.EnsureSeedDataForContext(); //添加种子数据
     app.UseStatusCodePages();
     //使用mvc来处理http请求:注意顺序, 应该在处理异常的中间件后边调用app.UseMvc(),
     //所以处理异常的middleware可以在把request交给mvc之间就处理异常, 更重要的是它还可以捕获并处理MVC返回的相关代码中的异常.
     app.UseMvc();
 }
 public DeadlinesController(MyContext db) : base(db)
 {
 }
Exemple #53
0
 public NabavkaController(MyContext context)
 {
     _context = context;
 }
Exemple #54
0
 public CouncilsController(MyContext context, IOptions <AppSettings> settings)
 {
     this._context   = context;
     this.auth       = new AuthService(this._context);
     this.jwtService = new TokenService(this._context, settings);
 }
Exemple #55
0
 public InviteController(MyContext context)
 {
     _context = context;
 }
Exemple #56
0
 public SignUpModel(MyContext db)
 {
     _db = db;
 }
        public void Only_unresolved_issues_should_be_retried()
        {
            var context = new MyContext();

            FailedMessage messageToBeRetriedAsPartOfGroupRetry = null;
            FailedMessage messageToBeArchived = null;

            Define(context)
            .WithEndpoint <Receiver>(b => b.Given(bus =>
            {
                bus.SendLocal <MyMessage>(m => m.MessageNumber = 1);
                bus.SendLocal <MyMessage>(m => m.MessageNumber = 2);
            }))
            .Done(c =>
            {
                if (c.MessageToBeRetriedByGroupId == null || c.MessageToBeArchivedId == null)
                {
                    return(false);
                }

                //First we are going to issue an archive to one of the messages
                if (!c.ArchiveIssued)
                {
                    if (!TryGet("/api/errors/" + c.MessageToBeArchivedId, out messageToBeArchived, e => e.Status == FailedMessageStatus.Unresolved))
                    {
                        return(false);
                    }

                    Patch <object>($"/api/errors/{messageToBeArchived.UniqueMessageId}/archive");

                    c.ArchiveIssued = true;

                    return(false);
                }

                //We are now going to issue a retry group
                if (!c.RetryIssued)
                {
                    // Ensure message is being retried
                    if (!TryGet("/api/errors/" + c.MessageToBeRetriedByGroupId, out messageToBeRetriedAsPartOfGroupRetry, e => e.Status == FailedMessageStatus.Unresolved))
                    {
                        return(false);
                    }

                    c.RetryIssued = true;

                    Post <object>($"/api/recoverability/groups/{messageToBeRetriedAsPartOfGroupRetry.FailureGroups[0].Id}/errors/retry");

                    return(false);
                }

                if (!TryGet("/api/errors/" + c.MessageToBeRetriedByGroupId, out messageToBeRetriedAsPartOfGroupRetry, e => e.Status == FailedMessageStatus.Resolved))
                {
                    return(false);
                }

                if (!TryGet("/api/errors/" + c.MessageToBeArchivedId, out messageToBeArchived, e => e.Status == FailedMessageStatus.Archived))
                {
                    return(false);
                }

                return(true);
            })
            .Run(TimeSpan.FromMinutes(2));

            Assert.AreEqual(FailedMessageStatus.Archived, messageToBeArchived.Status, "Non retried message should be archived");
            Assert.AreEqual(FailedMessageStatus.Resolved, messageToBeRetriedAsPartOfGroupRetry.Status, "Retried Message should not be set to Archived when group is retried");
        }
Exemple #58
0
 public BaseRepository()
 {
     _db = DBTool.DBInstance;
 }
 public EmployeeService(IContentService contentService, MyContext context)
 {
     this.contentService = contentService;
     this.context        = context;
 }
Exemple #60
0
 public MenuInfoRepository(MyContext myContext) : base(myContext)
 {
     _myContext = myContext;
 }