Exemple #1
0
        /// <summary>
        /// Seeds analytics database.
        /// </summary>
        /// <param name="repository"></param>
        public static void SeedDatabase(IRepository <ReportDb> repository)
        {
            var report = new ReportDb()
            {
                Id          = Guid.NewGuid().ToString(),
                Name        = "Основной отчет",
                Description = "Описание основного отчета",
                Created     = DateTime.Now,
                Modified    = DateTime.Now,
                Creator     = "Создатель отчета",
                Modifier    = "Модификатор отчета",
                Dashboards  = new List <DashboardDb>()
                {
                    new DashboardDb()
                    {
                        Id       = Guid.NewGuid().ToString(),
                        ChartId  = 1,
                        Created  = DateTime.Now,
                        Modified = DateTime.Now,
                        Creator  = "Создатель дашборда",
                        Modifier = "Модификатор дашборда",
                        Name     = "Дашборд 1"
                    }
                }
            };

            repository.CreateAsync(report);
        }
Exemple #2
0
        protected override void Seed(BulbaCourses.Analytics.DAL.Context.AnalyticsContext context)
        {
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method
            //  to avoid creating duplicate seed data.
            var reportId = Guid.NewGuid().ToString();
            var report   = new ReportDb()
            {
                Id          = reportId,
                Name        = "Основной отчет",
                Description = "Описание основного отчета",
                Created     = DateTime.Now,
                Modified    = DateTime.Now,
                Creator     = "Создатель отчета",
                Modifier    = "Модификатор отчета",
                Dashboards  = new List <DashboardDb>()
                {
                    new DashboardDb()
                    {
                        Id       = Guid.NewGuid().ToString(),
                        ChartId  = 1,
                        Created  = DateTime.Now,
                        Modified = DateTime.Now,
                        Creator  = "Создатель дашборда",
                        Modifier = "Модификатор дашборда",
                        Name     = "Дашборд 1",
                        ReportId = reportId
                    }
                }
            };
            var cart = new ChartDb()
            {
                Id   = 1,
                Name = "Line"
            };

            context.Reports.Add(report);
            context.Charts.Add(cart);
            context.SaveChanges();
        }