コード例 #1
0
        private static void SeedOnDebug(ApiContext context)
        {
            if (!context.Contacts.Any())
            {
                var file = File.ReadAllText(
                    "seed" + Path.DirectorySeparatorChar + "Contacts.json");
                var types = JsonConvert.DeserializeObject <List <Contact> >(file);
                context.AddRange(types);
            }
            if (!context.Enquiries.Any())
            {
                var types = JsonConvert.DeserializeObject <List <Enquiry> >(
                    File.ReadAllText(
                        "seed" + Path.DirectorySeparatorChar + "Enquiries.json"));
                context.AddRange(types);
            }

            if (!context.DeviceMasters.Any())
            {
                var types = JsonConvert.DeserializeObject <List <DeviceMaster> >(
                    File.ReadAllText(
                        "seed" + Path.DirectorySeparatorChar + "Devices.json")
                    );
                context.AddRange(types);
            }
            context.SaveChanges();
        }
コード例 #2
0
 private static void SeedEnquiries(ApiContext context)
 {
     if (!context.Contacts.Any())
     {
         var file = File.ReadAllText(
             SeedPath + Path.DirectorySeparatorChar + "Contacts.json");
         var types = JsonConvert.DeserializeObject <List <Contact> >(file);
         context.AddRange(types);
         context.SaveChanges();
     }
     if (!context.Enquiries.Any())
     {
         var types = JsonConvert.DeserializeObject <List <Enquiry> >(
             File.ReadAllText(
                 SeedPath + Path.DirectorySeparatorChar + "Enquiries.json"));
         context.AddRange(types);
         context.SaveChanges();
     }
     if (!context.EnquiryItems.Any())
     {
         var types = JsonConvert.DeserializeObject <List <EnquiryCatalogItem> >(
             File.ReadAllText(
                 SeedPath + Path.DirectorySeparatorChar + "EnquiryProducts.json"));
         context.AddRange(types);
         context.SaveChanges();
     }
 }
コード例 #3
0
ファイル: SeedData.cs プロジェクト: K7696/II013200-job
            /// <summary>
            /// Init stories
            /// </summary>
            /// <param name="context"></param>
            private static void initStories(ApiContext context)
            {
                // Look for any stories
                if (context.Stories.Any())
                {
                    return;   // DB has been seeded
                }

                context.AddRange(
                    new Story {
                    CompanyId          = 1,
                    ProjectId          = 1,
                    FeatureId          = 1,
                    AcceptanceCriteria = "Muista lisätä hyväksyntäkriteerit",
                    Priority           = 1,
                    ObjectId           = Guid.NewGuid(),
                    ShortCode          = "S1",
                    Name        = "Story 1",
                    Description = "Story 1",
                    Created     = DateTime.Now,
                    Modified    = DateTime.Now,
                    CreatorId   = 1,
                    ModifierId  = 1
                },
                    new Story {
                    CompanyId          = 1,
                    ProjectId          = 1,
                    FeatureId          = 1,
                    AcceptanceCriteria = "Muista lisätä hyväksyntäkriteerit",
                    Priority           = 1,
                    ObjectId           = Guid.NewGuid(),
                    ShortCode          = "S2",
                    Name        = "Story 2",
                    Description = "Story 2",
                    Created     = DateTime.Now,
                    Modified    = DateTime.Now,
                    CreatorId   = 1,
                    ModifierId  = 1
                },
                    new Story {
                    CompanyId          = 1,
                    ProjectId          = 1,
                    FeatureId          = 1,
                    AcceptanceCriteria = "Muista lisätä hyväksyntäkriteerit",
                    Priority           = 1,
                    ObjectId           = Guid.NewGuid(),
                    ShortCode          = "S3",
                    Name        = "Story 3",
                    Description = "Story 3",
                    Created     = DateTime.Now,
                    Modified    = DateTime.Now,
                    CreatorId   = 1,
                    ModifierId  = 1
                }
                    );
            }
コード例 #4
0
        public static void EnsureSeeded(this ApiContext context)
        {
            if (!context.Type.Any())
            {
                var types = JsonConvert.DeserializeObject <List <ThreatType> >(File.ReadAllText("seed" + Path.DirectorySeparatorChar + "types.json"));
                context.AddRange(types);
                context.SaveChanges();
            }

            //Ensure we have some status
            if (!context.Status.Any())
            {
                var stati = JsonConvert.DeserializeObject <List <Status> >(File.ReadAllText(@"seed" + Path.DirectorySeparatorChar + "status.json"));
                context.AddRange(stati);
                context.SaveChanges();
            }
            //Ensure we create initial Threat List
            if (!context.Threats.Any())
            {
                var threats = JsonConvert.DeserializeObject <List <Threat> >(File.ReadAllText(@"seed" + Path.DirectorySeparatorChar + "threats.json"));
                context.AddRange(threats);
                context.SaveChanges();
            }
        }
コード例 #5
0
        public static void EnsureSeeded(this ApiContext context)
        {
            #region CRM Seeds

            #region Address
            string path = $"seed" +
                          $"{Path.DirectorySeparatorChar}" +
                          $"Address{Path.DirectorySeparatorChar}";
            if (!context.States.Any())
            {
                var types = JsonConvert.DeserializeObject <List <StateMaster> >(
                    File.ReadAllText($"{path}State.json"));
                context.AddRange(types);
                context.SaveChanges();
            }
            if (!context.Districts.Any())
            {
                var types = JsonConvert.DeserializeObject <List <DistrictMaster> >(
                    File.ReadAllText($"{path}District.json"));
                context.AddRange(types);
                context.SaveChanges();
            }
            if (!context.SubDistricts.Any())
            {
                var types = JsonConvert.DeserializeObject <List <SubDistrictMaster> >(
                    File.ReadAllText($"{path}SubDistrict.json"));
                context.AddRange(types);
                context.SaveChanges();
            }
            if (!context.Localities.Any())
            {
                var types = JsonConvert.DeserializeObject <List <LocalityOrVillageMaster> >(
                    File.ReadAllText($"{path}LocalityVillage.json"));
                context.AddRange(types);
                context.SaveChanges();
            }
            if (!context.Pincodes.Any())
            {
                var types = JsonConvert.DeserializeObject <List <PincodeMaster> >(
                    File.ReadAllText($"{path}Pincode.json"));
                context.AddRange(types);
                context.SaveChanges();
            }
            #endregion

            //TODO: Need to move CRM Seeds inside this region.
            if (!context.LeadStatusMasters.Any())
            {
                var types = JsonConvert.DeserializeObject <List <LeadStatusMaster> >(
                    File.ReadAllText(
                        "seed" + Path.DirectorySeparatorChar + "LeadStatusMaster.json")
                    );
                context.AddRange(types);
                context.SaveChanges();
            }
            #endregion

            #region Point of Sales Seeds
            if (!context.CatalogBrands.Any())
            {
                var types = JsonConvert.DeserializeObject <List <CatalogBrand> >(
                    File.ReadAllText(
                        "seed" + Path.DirectorySeparatorChar + "pos\\BrandMaster.json")
                    );
                context.AddRange(types);
                context.SaveChanges();
            }

            if (!context.Categories.Any())
            {
                var types = JsonConvert.DeserializeObject <List <CategoryMaster> >(
                    File.ReadAllText(
                        "seed" + Path.DirectorySeparatorChar + "pos\\CategoryMaster.json")
                    );
                context.AddRange(types);
                context.SaveChanges();
            }
            #endregion

            if (!context.InquiryReport.Any())
            {
                var types = JsonConvert.DeserializeObject <List <InquiryReport> >(
                    File.ReadAllText(
                        "seed" + Path.DirectorySeparatorChar + "InquiryReport.json")
                    );
                context.AddRange(types);
                context.SaveChanges();
            }
            if (!context.BranchMasters.Any())
            {
                var types = JsonConvert.DeserializeObject <List <BranchMaster> >(File.ReadAllText("seed" + Path.DirectorySeparatorChar + "BranchMaster.json"));

                context.AddRange(types);
                context.SaveChanges();
            }


            if (!context.marketingZones.Any())
            {
                var types = JsonConvert.DeserializeObject <List <MarketingZone> >(File.ReadAllText("seed" + Path.DirectorySeparatorChar + "MarketingZones.json"));
                context.AddRange(types);
                context.SaveChanges();
            }
            if (!context.EnquiryStatuses.Any())
            {
                var types = JsonConvert.DeserializeObject <List <EnquiryStatus> >(File.ReadAllText("seed" + Path.DirectorySeparatorChar + "EnquiryStatus.json"));
                context.AddRange(types);
                context.SaveChanges();
            }
            if (!context.EnquriyType.Any())
            {
                var types = JsonConvert.DeserializeObject <List <EnquiryType> >(File.ReadAllText("seed" + Path.DirectorySeparatorChar + "EnquiryType.json"));
                context.AddRange(types);
                context.SaveChanges();
            }
            if (!context.CatalogBrands.Any())
            {
                var types = JsonConvert.DeserializeObject <List <CatalogBrand> >(File.ReadAllText("seed" + Path.DirectorySeparatorChar + "ProductCompanies.json"));
                context.AddRange(types);
                context.SaveChanges();
            }
            if (!context.CatalogTypes.Any())
            {
                var types = JsonConvert.DeserializeObject <List <CatalogType> >(File.ReadAllText("seed" + Path.DirectorySeparatorChar + "ProductTypes.json"));
                context.AddRange(types);
                context.SaveChanges();
            }
            if (!context.LicenseMasters.Any())
            {
                var types = JsonConvert.DeserializeObject <List <LicenseMaster> >(File.ReadAllText("seed" + Path.DirectorySeparatorChar + "LIcense.json"));
                context.AddRange(types);
                context.SaveChanges();
            }
            if (!context.PaymentModes.Any())
            {
                var types = JsonConvert.DeserializeObject <List <PaymentMode> >(File.ReadAllText("seed" + Path.DirectorySeparatorChar + "PaymentMode.json"));
                context.AddRange(types);
                context.SaveChanges();
            }
            if (!context.FinanceCompanies.Any())
            {
                var types = JsonConvert.DeserializeObject <List <FinanceCompany> >(File.ReadAllText("seed" + Path.DirectorySeparatorChar + "FinanceCompanys.json"));
                context.AddRange(types);
                context.SaveChanges();
            }
            if (!context.FollowUpModes.Any())
            {
                var types = JsonConvert.DeserializeObject <List <FollowUpMode> >(
                    File.ReadAllText(
                        "seed" + Path.DirectorySeparatorChar + "FollowUpModes.json"));
                context.AddRange(types);
                context.SaveChanges();
            }
            if (!context.FollowUpStatuses.Any())
            {
                var types = JsonConvert.DeserializeObject <List <FollowUpStatus> >(
                    File.ReadAllText(
                        "seed" + Path.DirectorySeparatorChar + "FollowUpStatuses.json"));
                context.AddRange(types);
                context.SaveChanges();
            }
            if (!context.LeadSources.Any())
            {
                var file = File.ReadAllText(
                    "seed" + Path.DirectorySeparatorChar + "LeadSource.json");
                var types = JsonConvert.DeserializeObject <List <LeadSource> >(file);
                context.AddRange(types);
            }
            if (!context.StatusMasters.Any())
            {
                var file = File.ReadAllText(
                    "seed" + Path.DirectorySeparatorChar + "StatusMasters.json");
                var types = JsonConvert.DeserializeObject <List <StatusMaster> >(file);
                context.AddRange(types);
            }
            if (!context.RoleGroup.Any())
            {
                var types = JsonConvert.DeserializeObject <List <RoleGroupMaster> >(
                    File.ReadAllText(
                        "seed" + Path.DirectorySeparatorChar + "RoleGroupMaster.json"));
                context.AddRange(types);
                context.SaveChanges();
            }
            SeedOnDebug(context);
            if (!context.VoucherTypeMasters.Any())
            {
                var types = JsonConvert.DeserializeObject <List <VoucherTypeMaster> >(
                    File.ReadAllText(
                        "seed" + Path.DirectorySeparatorChar + "VoucherTypeMaster.json"));
                context.AddRange(types);
                context.SaveChanges();
            }
            if (!context.AccountBooks.Any())
            {
                var types = JsonConvert.DeserializeObject <List <AccountBook> >(
                    File.ReadAllText(
                        "seed" + Path.DirectorySeparatorChar + "AccountBook.json"));
                context.AddRange(types);
                context.SaveChanges();
            }
        }
コード例 #6
0
        private void SeedCustomers(int amount)
        {
            List <Customer> customers = BuildCustomerList(amount);

            _context.AddRange(customers);
        }
コード例 #7
0
        public static void Seed(ApiContext context)
        {
            if (!context.CatalogItems.Any())
            {
                var types = JsonConvert.DeserializeObject <List <CatalogItem> >(File.ReadAllText(SeedPath + Path.DirectorySeparatorChar + "products.json"));

                context.AddRange(types);
                context.SaveChanges();
            }
            if (!context.marketingZones.Any())
            {
                var types = JsonConvert.DeserializeObject <List <MarketingZone> >(File.ReadAllText(SeedPath + Path.DirectorySeparatorChar + "MarketingZones.json"));
                context.AddRange(types);
                context.SaveChanges();
            }
            if (!context.EnquiryStatuses.Any())
            {
                var types = JsonConvert.DeserializeObject <List <EnquiryStatus> >(File.ReadAllText(SeedPath + Path.DirectorySeparatorChar + "EnquiryStatus.json"));
                context.AddRange(types);
                context.SaveChanges();
            }
            if (!context.EnquriyType.Any())
            {
                var types = JsonConvert.DeserializeObject <List <EnquiryType> >(File.ReadAllText(SeedPath + Path.DirectorySeparatorChar + "EnquiryType.json"));
                context.AddRange(types);
                context.SaveChanges();
            }
            if (!context.CatalogBrands.Any())
            {
                var types = JsonConvert.DeserializeObject <List <CatalogBrand> >(File.ReadAllText(SeedPath + Path.DirectorySeparatorChar + "ProductCompanies.json"));
                context.AddRange(types);
                context.SaveChanges();
            }
            if (!context.CatalogTypes.Any())
            {
                var types = JsonConvert.DeserializeObject <List <CatalogType> >(File.ReadAllText(SeedPath + Path.DirectorySeparatorChar + "ProductTypes.json"));
                context.AddRange(types);
                context.SaveChanges();
            }
            if (!context.LicenseMasters.Any())
            {
                var types = JsonConvert.DeserializeObject <List <LicenseMaster> >(File.ReadAllText(SeedPath + Path.DirectorySeparatorChar + "LIcense.json"));
                context.AddRange(types);
                context.SaveChanges();
            }
            if (!context.PaymentModes.Any())
            {
                var types = JsonConvert.DeserializeObject <List <PaymentMode> >(File.ReadAllText(SeedPath + Path.DirectorySeparatorChar + "PaymentMode.json"));
                context.AddRange(types);
                context.SaveChanges();
            }
            if (!context.FinanceCompanies.Any())
            {
                var types = JsonConvert.DeserializeObject <List <FinanceCompany> >(File.ReadAllText(SeedPath + Path.DirectorySeparatorChar + "FinanceCompanys.json"));
                context.AddRange(types);
                context.SaveChanges();
            }
            if (!context.FollowUpModes.Any())
            {
                var types = JsonConvert.DeserializeObject <List <FollowUpMode> >(
                    File.ReadAllText(
                        SeedPath + Path.DirectorySeparatorChar + "FollowUpModes.json"));
                context.AddRange(types);
                context.SaveChanges();
            }
            if (!context.FollowUpStatuses.Any())
            {
                var types = JsonConvert.DeserializeObject <List <FollowUpStatus> >(
                    File.ReadAllText(
                        SeedPath + Path.DirectorySeparatorChar + "FollowUpStatuses.json"));
                context.AddRange(types);
                context.SaveChanges();
            }
            SeedEnquiries(context);
        }