コード例 #1
0
ファイル: Resume.cs プロジェクト: shortpoet/Shortpoet
        public static Resume LoadType(ResumeDbContext context, string path, Boolean writeJson)
        {
            using (StreamReader r = new StreamReader(path))
            {
                var deserializer = new Deserializer();
                var yamlObject   = deserializer.Deserialize(r);

                var serializer = new Newtonsoft.Json.JsonSerializer();
                serializer.Formatting = Newtonsoft.Json.Formatting.Indented;

                string json;
                using (StringWriter w = new StringWriter())
                {
                    serializer.Serialize(w, yamlObject);
                    json = w.ToString();
                }

                if (writeJson)
                {
                    string jsonPath = path.Replace("yml", "json");
                    using (StreamWriter w2 = new StreamWriter(jsonPath))
                    {
                        w2.Write(json);
                    }
                }

                Resume resume = JsonConvert.DeserializeObject <Resume>(json);

                context.Add(resume);

                return(resume);
            }
        }
コード例 #2
0
        public static IList <SpokenLanguages> LoadType(ResumeDbContext context, string path, Boolean writeJson)
        {
            using (StreamReader r = new StreamReader(path))
            {
                var deserializer = new Deserializer();
                var yamlObject   = deserializer.Deserialize(r);

                var serializer = new Newtonsoft.Json.JsonSerializer();
                serializer.Formatting = Newtonsoft.Json.Formatting.Indented;

                string json;
                using (StringWriter w = new StringWriter())
                {
                    serializer.Serialize(w, yamlObject);
                    json = w.ToString();
                }

                if (writeJson)
                {
                    string jsonPath = path.Replace("yml", "json");
                    using (StreamWriter w2 = new StreamWriter(jsonPath))
                    {
                        w2.Write(json);
                    }
                }

                // string json = r.ReadToEnd();

                SpokenLanguagesJson spokenLanguages = JsonConvert.DeserializeObject <SpokenLanguagesJson>(json);
                context.Add(spokenLanguages.SpokenLanguages);
                return(spokenLanguages.SpokenLanguages);
            }
        }
コード例 #3
0
 public static void AddItemsReverse <T> (ResumeDbContext context, IList <T> list)
 {
     foreach (var item in list.Reverse())
     {
         context.Add(item);
     }
 }
コード例 #4
0
        public static void AddResume(ResumeDbContext context, string dateFolder)
        {
            try
            {
                // add this check so resume doesn't get imported twice
                if (dateFolder[0] == 'r')
                {
                    ResumeFiles files = new ResumeFiles(dateFolder);

                    // Utilities.LoadType<Resume>(context, $"{ResumeFileStrings.ProjectRoot}/{dateFolder}/{ResumeFileStrings.Resume}", writeJson);

                    if (File.Exists(files.Resume))
                    {
                        Resume resume = Utilities.SerializeYml <Resume>(files.Resume);
                        context.Add(resume);
                    }

                    context.SaveChanges();

                    if (File.Exists(files.ResumeEducations))
                    {
                        ResumeEducationsJson     resumeEducationsJson = Utilities.SerializeYml <ResumeEducationsJson>(files.ResumeEducations);
                        IList <ResumeEducations> resumeEducations     = resumeEducationsJson.ResumeEducations;
                        AddItemsReverse(context, resumeEducations);
                    }
                    if (File.Exists(files.ResumeJobs))
                    {
                        ResumeJobsJson     resumeJobsJson = Utilities.SerializeYml <ResumeJobsJson>(files.ResumeJobs);
                        IList <ResumeJobs> resumeJobs     = resumeJobsJson.ResumeJobs;
                        AddItemsReverse(context, resumeJobs);
                    }
                    if (File.Exists(files.ResumeSkills))
                    {
                        ResumeSkillsJson     resumeSkillsJson = Utilities.SerializeYml <ResumeSkillsJson>(files.ResumeSkills);
                        IList <ResumeSkills> resumeSkills     = resumeSkillsJson.ResumeSkills;
                        AddItemsReverse(context, resumeSkills);
                    }
                    if (File.Exists(files.ResumeSocials))
                    {
                        ResumeSocialsJson     resumeSocialsJson = Utilities.SerializeYml <ResumeSocialsJson>(files.ResumeSocials);
                        IList <ResumeSocials> resumeSocials     = resumeSocialsJson.ResumeSocials;
                        AddItemsReverse(context, resumeSocials);
                    }
                    if (File.Exists(files.ResumeSpokenLanguages))
                    {
                        ResumeSpokenLanguagesJson     resumeSpokenLanguagesJson = Utilities.SerializeYml <ResumeSpokenLanguagesJson>(files.ResumeSpokenLanguages);
                        IList <ResumeSpokenLanguages> resumeSpokenLanguages     = resumeSpokenLanguagesJson.ResumeSpokenLanguages;
                        AddItemsReverse(context, resumeSpokenLanguages);
                    }

                    context.SaveChanges();
                }
            } catch (Exception e)
            {
                Console.WriteLine("##############################");
                Console.WriteLine("Resume Add Fail");
                Console.WriteLine(e);
            }
        }
コード例 #5
0
        public static async Task <Result> Insert(ResumeDbContext db, FootballTeam footballTeam)
        {
            Result vtr = new Result();

            vtr.SetError("Prohibited from inserting a new football team"); //<-- The only allowed place to insert a new team is in the hostedservice, which is a singleton and uses the singleton version of the dbcontext. I felt that I should not remove the method from the parent IRootAggregateRepository since there is also PaymentRecipt which can be inserted from a scoped perspective.

            return(vtr);
        }
コード例 #6
0
        public static void AddResumeData(ResumeDbContext context, string dateFolder)
        {
            try
            {
                if (dateFolder[0] == 'd')
                {
                    ResumeFiles files = new ResumeFiles(dateFolder);

                    // Utilities.LoadType<Resume>(context, files.Resume, writeJson);

                    if (File.Exists(files.Resume))
                    {
                        Resume resume = Utilities.SerializeYml <Resume>(files.Resume);
                        context.Add(resume);
                    }

                    if (File.Exists(files.Education))
                    {
                        EducationJson     educationJson = Utilities.SerializeYml <EducationJson>(files.Education);
                        IList <Education> educations    = educationJson.Educations;
                        AddItems(context, educations);
                    }
                    if (File.Exists(files.Job))
                    {
                        JobJson     jobJson = Utilities.SerializeYml <JobJson>(files.Job);
                        IList <Job> jobs    = jobJson.Jobs;
                        AddItems(context, jobs);
                    }
                    if (File.Exists(files.Skill))
                    {
                        SkillJson     skillJson = Utilities.SerializeYml <SkillJson>(files.Skill);
                        IList <Skill> skills    = skillJson.Skills;
                        AddItems(context, skills);
                    }
                    if (File.Exists(files.Social))
                    {
                        SocialJson     socialJson = Utilities.SerializeYml <SocialJson>(files.Social);
                        IList <Social> socials    = socialJson.Socials;
                        AddItems(context, socials);
                    }
                    if (File.Exists(files.SpokenLanguages))
                    {
                        SpokenLanguagesJson     spokenLanguagesJson = Utilities.SerializeYml <SpokenLanguagesJson>(files.SpokenLanguages);
                        IList <SpokenLanguages> spokenLanguages     = spokenLanguagesJson.SpokenLanguages;
                        AddItems(context, spokenLanguages);
                    }

                    context.SaveChanges();
                }
            }

            catch (Exception e)
            {
                Console.WriteLine("##############################");
                Console.WriteLine("Resume Data Add Fail");
                Console.WriteLine(e);
            }
        }
コード例 #7
0
        public UnitOfWork(ResumeDbContext resumeDbContext, VisitIdProvider visitIdProvider)
        {
            this.resumeDbContext = resumeDbContext ?? throw new ArgumentNullException("dbContext can not be null.");
            this.visitId         = visitIdProvider.VisitId;

            // Buradan istediğiniz gibi EntityFramework'ü konfigure edebilirsiniz.
            //this.appDbContext.Configuration.LazyLoadingEnabled = false;
            //_dbContext.Configuration.ValidateOnSaveEnabled = false;
            //_dbContext.Configuration.ProxyCreationEnabled = false;
        }
コード例 #8
0
 public static IEnumerable <Resume> Getxbyx(this ResumeDbContext resumeDbContext, int row, int itemperRow)
 {
     return(resumeDbContext.Resumes
            .OrderBy(x => x.StartDate).Skip((row - 1) * itemperRow).Take(itemperRow).Select(x => new Resume
     {
         Id = x.Id,
         About = x.About,
         AuthorId = x.AuthorId,
         StartDate = x.StartDate,
         EndDate = x.EndDate,
         WorkName = x.WorkName,
         WorkPlace = x.WorkPlace
     }).ToList());
 }
コード例 #9
0
        public static void InitializeDb(ResumeDbContext context)
        {
            // COMMENT THIS IS PRODUCTION OR EVEN REMOVE
            // context.Database.EnsureCreated();

            // Look for any dashboards.
            if (context.Resumes.Any())
            {
                return; // DB has been seeded
            }

            AddResume.Seed(context);

            Console.WriteLine("#######################");
            Console.WriteLine("Seed Data Context Changes Saved");
        }
コード例 #10
0
        public static void Seed(ResumeDbContext context)
        {
            AddItems(context, EducationJson.LoadJson("Data/Seed/carlos_resume_educations.json").Educations);
            AddItems(context, JobJson.LoadJson("Data/Seed/carlos_resume_jobs.json").Jobs);
            context.Add(Resume.LoadJson("Data/Seed/carlos_resume_about.json"));
            AddItems(context, SkillJson.LoadJson("Data/Seed/carlos_resume_skills.json").Skills);
            AddItems(context, SocialJson.LoadJson("Data/Seed/carlos_resume_socials.json").Socials);
            AddItems(context, SpokenLanguagesJson.LoadJson("Data/Seed/carlos_resume_languages.json").SpokenLanguages);
            context.SaveChanges();

            AddItems(context, ResumeEducationsJson.LoadJson("Data/Seed/carlos_resume_resumeeducations.json").ResumeEducations);
            AddItems(context, ResumeJobsJson.LoadJson("Data/Seed/carlos_resume_resumejobs.json").ResumeJobs);
            AddItems(context, ResumeSkillsJson.LoadJson("Data/Seed/carlos_resume_resumeskills.json").ResumeSkills);
            AddItems(context, ResumeSocialsJson.LoadJson("Data/Seed/carlos_resume_resumesocials.json").ResumeSocials);
            AddItems(context, ResumeSpokenLanguagesJson.LoadJson("Data/Seed/carlos_resume_resumespokenlanguages.json").ResumeSpokenLanguages);
            context.SaveChanges();
        }
コード例 #11
0
        public static IList <Education> LoadType(ResumeDbContext context, string path, Boolean writeJson)
        {
            // if (File.Exists(filePath))
            // {
            //   Console.WriteLine("##############################");
            //   Console.WriteLine($"{filePath} written to database");
            // }
            // else
            // {
            //   Console.WriteLine("##############################");
            //   Console.WriteLine($"No such file at: {filePath}");
            // }
            using (StreamReader r = new StreamReader(path))
            {
                var deserializer = new Deserializer();
                var yamlObject   = deserializer.Deserialize(r);

                var serializer = new Newtonsoft.Json.JsonSerializer();
                serializer.Formatting = Newtonsoft.Json.Formatting.Indented;

                string json;
                using (StringWriter w = new StringWriter())
                {
                    serializer.Serialize(w, yamlObject);
                    json = w.ToString();
                }

                if (writeJson)
                {
                    string jsonPath = path.Replace("yml", "json");
                    using (StreamWriter w2 = new StreamWriter(jsonPath))
                    {
                        w2.Write(json);
                    }
                }

                // string json = r.ReadToEnd();

                EducationJson educations = JsonConvert.DeserializeObject <EducationJson>(json);

                context.Add(educations.Educations);

                return(educations.Educations);
            }
        }
コード例 #12
0
        public static void LoadType <T>(ResumeDbContext context, string filePath, Boolean writeJson)
        {
            if (File.Exists(filePath))
            {
                using (StreamReader r = new StreamReader(filePath))
                {
                    var deserializer = new Deserializer();
                    var yamlObject   = deserializer.Deserialize(r);

                    var serializer = new Newtonsoft.Json.JsonSerializer();
                    serializer.Formatting = Newtonsoft.Json.Formatting.Indented;

                    string json;
                    using (StringWriter w = new StringWriter())
                    {
                        serializer.Serialize(w, yamlObject);
                        json = w.ToString();
                    }

                    if (writeJson)
                    {
                        string jsonPath = filePath.Replace("yml", "json");
                        using (StreamWriter w2 = new StreamWriter(jsonPath))
                        {
                            w2.Write(json);
                        }
                    }

                    // string json = r.ReadToEnd();

                    T output = JsonConvert.DeserializeObject <T>(json);

                    context.Add(output);
                }

                Console.WriteLine("##############################");
                Console.WriteLine($"{filePath} written to database");
            }
            else
            {
                Console.WriteLine("##############################");
                Console.WriteLine($"No such file at: {filePath}");
            }
        }
コード例 #13
0
        public static void Add(ResumeDbContext context, string dateFolder)
        {
            try
            {
                // Boolean writeJson = true;
                // context.Add(Resume.LoadResume($"Data/Resumes/{dateFolder}/carlos_resume_about.yml", writeJson));
                // context.SaveChanges();

                // AddItems(context, ResumeEducationsJson.LoadResumeEducations($"Data/Resumes/{dateFolder}/carlos_resume_resumeeducations.yml", writeJson).ResumeEducations);
                // AddItems(context, ResumeJobsJson.LoadResumeJobs($"Data/Resumes/{dateFolder}/carlos_resume_resumejobs.yml", writeJson).ResumeJobs);
                // AddItems(context, ResumeSkillsJson.LoadResumeSkills($"Data/Resumes/{dateFolder}/carlos_resume_resumeskills.yml", writeJson).ResumeSkills);
                // AddItems(context, ResumeSocialsJson.LoadResumeSocials($"Data/Resumes/{dateFolder}/carlos_resume_resumesocials.yml", writeJson).ResumeSocials);
                // AddItems(context, ResumeSpokenLanguagesJson.LoadResumeSpokenLanguages($"Data/Resumes/{dateFolder}/carlos_resume_resumespokenlanguages.yml", writeJson).ResumeSpokenLanguages);
                // context.SaveChanges();
            } catch (Exception e)
            {
                // Console.WriteLine("##############################");
                // Console.WriteLine("Resume Add Fail");
                // Console.WriteLine(e);
            }
        }
コード例 #14
0
ファイル: DbConnect.cs プロジェクト: shortpoet/Shortpoet
 // public static Resume GetResume (DbContextOptions<ResumeDbContext> options)
 // {
 //   using (var db = new ResumeDbContext(options))
 //   {
 //     var resume = db.Resumes
 //       .Include(r => r.ResumeEducations)
 //         .ThenInclude(r => r.Education)
 //       .Include(r => r.ResumeJobs)
 //         .ThenInclude(r => r.Job)
 //       .Include(r => r.ResumeSkills)
 //         .ThenInclude(r => r.Skill)
 //       .Include(r => r.ResumeSocials)
 //         .ThenInclude(r => r.Social)
 //       .Include(r => r.ResumeSpokenLanguages)
 //         .ThenInclude(r => r.SpokenLanguages)
 //       .AsNoTracking()
 //       .OrderByDescending(r => r.DateCreated)
 //       .FirstOrDefault();
 //     return resume;
 //   }
 // }
 public static Resume GetLatestResume(DbContextOptions <ResumeDbContext> options)
 {
     using (var db = new ResumeDbContext(options))
     {
         var resume = db.Resumes
                      .Include(r => r.ResumeEducations)
                      .ThenInclude(r => r.Education)
                      .Include(r => r.ResumeJobs)
                      .ThenInclude(r => r.Job)
                      .Include(r => r.ResumeSkills)
                      .ThenInclude(r => r.Skill)
                      .Include(r => r.ResumeSocials)
                      .ThenInclude(r => r.Social)
                      .Include(r => r.ResumeSpokenLanguages)
                      .ThenInclude(r => r.SpokenLanguages)
                      .AsNoTracking()
                      .OrderByDescending(r => r.DateCreated)
                      .FirstOrDefault();
         return(resume);
     }
 }
コード例 #15
0
 public ResumesController()
 {
     _resumeDbContext = new ResumeDbContext();
 }
コード例 #16
0
 public static Result <List <FootballTeam> > GetDetachedFromDatabase(ResumeDbContext db, Predicate <FootballTeam> predicate)
 {
     return(ProcessGetDetachedFromDatabase(db.FootballTeam.AsEnumerable(), predicate));
 }
コード例 #17
0
 public static async Task <Result> Update(ResumeDbContext db, FootballTeam footballTeam)
 {
     return(await ProcessUpdate(e => db.Update(e), async() => await db.SaveChangesAsync(), footballTeam));
 }
コード例 #18
0
 public RootAggregateRepositoryScopedFootballTeam(ResumeDbContext db)
 {
     this.db = db;
 }
コード例 #19
0
 public PersonRepository(ResumeDbContext db)
 {
     this.db = db;
 }
コード例 #20
0
 public BlogController(ResumeDbContext db)
 {
     _db = db;
 }
コード例 #21
0
 public ServicesController()
 {
     _resumeDbContext = new ResumeDbContext();
 }
コード例 #22
0
 public ProjectsController()
 {
     _resumeDbContext = new ResumeDbContext();
 }
コード例 #23
0
 public PostController(ResumeDbContext db, IWebHostEnvironment env)
 {
     _db  = db;
     _env = env;
 }
コード例 #24
0
 public ResumeController(ILogger <ResumeController> logger, ResumeDbContext context)
 {
     _logger  = logger;
     _context = context;
 }
コード例 #25
0
 public SkillsController()
 {
     _resumeDbContext = new ResumeDbContext();
 }
コード例 #26
0
 public ContactPostsController(ResumeDbContext db)
 {
     this.db = db;
 }
コード例 #27
0
 public HomeController(ResumeDbContext db)
 {
     this.db = db;
 }
コード例 #28
0
 public HomeController()
 {
     _resumeDbContext = new ResumeDbContext();
 }
コード例 #29
0
 public ResumeRepository(ResumeDbContext db)
 {
     this.db = db;
 }
コード例 #30
0
 public UsersController(ResumeDbContext context, UserManager <ResumeUser> userManager)
 {
     _context         = context;
     this.userManager = userManager;
 }