Example #1
0
 public IEnumerable <Company> GetAll()
 {
     using (var db = new JobsContext())
     {
         return(db.Companies.ToList());
     }
 }
        public Jobs GetJob(int jobId)
        {
            using var db = new JobsContext();
            var job = db.Jobs.FirstOrDefault(x => x.Id == jobId);

            return(job);
        }
Example #3
0
        public JobsService()
        {
            jobsList = new ObservableCollection <JobWrapper>();
            BindingOperations.EnableCollectionSynchronization(jobsList, _lock);

            db = new JobsContext();
        }
        public Company GetCompany(int companyId)
        {
            using var db = new JobsContext();
            var company = db.Companies.FirstOrDefault(x => x.Id == companyId);

            return(company);
        }
        public List <Jobs> Get3LatestJobs()
        {
            using var db = new JobsContext();
            var jobs = db.Jobs.OrderByDescending(x => x.DateCreated).Take(3).ToList();

            return(jobs);
        }
Example #6
0
 public IEnumerable <Job> GetAll()
 {
     using (var db = new JobsContext())
     {
         return(db.Jobs.Include(c => c.company).ToList());
     }
 }
Example #7
0
        private async Task <JobsContext> BuildJobsContext()
        {
            var conn = new SqliteConnection("Data Source=:memory:");
            await conn.OpenAsync();

            var options = new DbContextOptionsBuilder <JobsContext>()
                          .UseSqlite(conn)
                          .Options;

            var context = new JobsContext(options);

            await context.Database.EnsureCreatedAsync();

            // clear
            context.Jobs.RemoveRange(context.Jobs);

            // dummy jobs
            await context.Jobs.AddRangeAsync(new[]
            {
                new Job {
                    JobId = 1, Name = "job 1"
                },
                new Job {
                    JobId = 2, Name = "job 2"
                },
                new Job {
                    JobId = 3, Name = "job 3"
                },
            });

            await context.SaveChangesAsync();

            return(context);
        }
        public List <Jobs> GetAllJobsBPostal(string postalCode)
        {
            using var db = new JobsContext();
            List <Jobs> jobs = db.Jobs.Where(x => x.Company.Postalcode == postalCode).ToList();

            return(jobs);
        }
Example #9
0
        // GET: Article
        public ActionResult Index()
        {
            JobsContext jobsContext = new JobsContext();

            IEnumerable <Article> art = jobsContext.Ariticles.ToList();

            return(View(art));
        }
        public void DeleteJobById(int jobId)
        {
            using var db = new JobsContext();
            var jobToDelete = db.Jobs.Find(jobId);

            db.Jobs.Remove(jobToDelete);
            db.SaveChanges();
        }
Example #11
0
 public Job GetById(long jobId)
 {
     using (var db = new JobsContext())
     {
         return(db.Jobs.Include(c => c.company)
                .FirstOrDefault(c => c.id == jobId));
     }
 }
Example #12
0
        protected override void SetContextParams(JobsContext context)
        {
            base.SetContextParams(context);

            var ctx = (TestJobsContext)context;

            ctx.SessionId = Regex.Replace(Convert.ToBase64String(Guid.NewGuid().ToByteArray()), "[/+=]", "").Substring(11);
        }
Example #13
0
        public Job add(Job job)
        {
            using (var db = new JobsContext())
            {
                db.Jobs.Add(job);
                db.SaveChanges();
            }

            return(job);
        }
Example #14
0
        public IEnumerable <Job> GetJobs(JobsContext jobsContext)
        {
            var registeredTests = Assembly.Load(settings.SearchInAssemblyName).GetTypes().Where(x => x != typeof(ITestCase) && x != typeof(ITestCase) && typeof(ITestCase).IsAssignableFrom(x) && !x.IsAbstract);

            var jobsBuilder = new JobsBuilder <Type, TestCaseJob>(
                x => ReflectionHelper.GectConstructorParamTypes(x).Select(t => t.ParameterType),
                (t, d) => new TestCaseJob(t, (TestJobsContext)jobsContext, d.ToArray()));

            return(jobsBuilder.GetJobs(registeredTests));
        }
Example #15
0
        public Company add(Company company)
        {
            using (var db = new JobsContext())
            {
                db.Companies.Add(company);
                db.SaveChanges();
            }

            return(company);
        }
Example #16
0
 private static void GetCompanies()
 {
     using (var context = new JobsContext())
     {
         var companies = context.Companies.ToList();
         foreach (var company in companies)
         {
             Console.WriteLine(company.Name);
         }
     }
 }
 public JsonResult SearchJobsByTitle(string title, int count)
 {
     using (JobsContext db = new JobsContext())
     {
         return(new JsonResult()
         {
             Data = _repo.SearchJobsByTitle(title, count).ToList(),
             JsonRequestBehavior = JsonRequestBehavior.AllowGet,
         });
     }
 }
Example #18
0
 public IEnumerable <User> GetAll()
 {
     using (var db = new JobsContext())
     {
         return(db.Users.ToList().Select(x =>
         {
             x.Password = null;
             return x;
         }));
     }
 }
        //automapper?
        public Jobs UpdateJob(int jobIdToEdit, Jobs updateJobValues)
        {
            using var db = new JobsContext();
            var JobToEdit = db.Jobs.First(Jobs => Jobs.Id == jobIdToEdit);

            JobToEdit.Company     = updateJobValues.Company;
            JobToEdit.JobTitle    = updateJobValues.JobTitle;
            JobToEdit.Description = updateJobValues.Description;
            JobToEdit.Salary      = updateJobValues.Salary;
            JobToEdit.DateCreated = updateJobValues.DateCreated;
            db.SaveChanges();
            return(JobToEdit);
        }
Example #20
0
        public void GetJobsToRun_CronWorksInLocalTime(Int32 skip)
        {
            var dateTimeOffset     = DateTimeOffset.Now;
            var fromDateTimeOffset = dateTimeOffset.AddMinutes(-skip);
            var toDateTimeOffset   = dateTimeOffset.AddMinutes(skip);

            var jobStorageItem = new JobItem(sp => new EmptyJob1(), CronExpression.Parse($"{dateTimeOffset.Minute} {dateTimeOffset.Hour} * * *"));
            var jobsContext    = new JobsContext();

            jobsContext.JobItems.Add(jobStorageItem);

            var jobStorageItems = jobsContext.GetJobsToRun(fromDateTimeOffset, toDateTimeOffset);

            Assert.Single(jobStorageItems);
        }
Example #21
0
        public static bool ApplicationStatus(MultipleJobsModel model)
        {
            var post = JobsContext.ApplicationStatus(new tb_multiple_jobs()
            {
                employee_id        = model.Employee_id,
                multiple_jobs_id   = model.Multiple_jobs_id,
                applied_date       = model.Applied_date,
                registered_user_id = model.Registered_user_id,
                jobs_details_id    = model.Jobs_details_id,
            });

            if (post > 0)
            {
                return(true);
            }
            return(false);
        }
Example #22
0
 public List <WeatherForecast> WeatherForecasts()
 {
     using (var db = new JobsContext())
     {
         var rng = new Random();
         for (int i = 0; i < 10; i++)
         {
             db.WeatherForecasts.Add(new WeatherForecast
             {
                 DateFormatted = DateTime.Now.AddDays(i).ToString("d"),
                 TemperatureC  = rng.Next(-20, 55),
                 Summary       = Summaries[rng.Next(Summaries.Length)]
             });
         }
         db.SaveChanges();
         return(db.WeatherForecasts.ToList());
     }
 }
Example #23
0
        private static void PopulateAddressTable()
        {
            using (TransactionScope transaction = new TransactionScope())

            {
                using (JobsContext db = new JobsContext())
                {
                    #region//person1
                    //TO-DO:  check whether person exists first...
                    ContactPerson person1 = new ContactPerson {
                        FirstName = "Ray", LastName = "Oflite"
                    };
                    db.People.Add(person1);
                    db.SaveChanges();

                    Address person1Addr = new Address {
                        Street = "8 Adams", City = "Detroit", StateProvince = "MI", PostalCode = "01237", ContactPersonId = person1.Id
                    };
                    db.Addresses.Add(person1Addr);
                    #endregion
                    ////////////////////////////////////////

                    #region//person 'Brice'
                    var     Brice           = db.People.Where(p => p.FirstName == "Brice").Single();
                    Address personBriceAddr = new Address {
                        Street = "8 Adams", City = "Detroit", StateProvince = "MI", PostalCode = "01237", ContactPersonId = Brice.Id
                    };
                    db.Addresses.Add(personBriceAddr);
                    #endregion

                    try
                    {
                        db.SaveChanges();
                        transaction.Complete();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex);
                    }
                }
            }
        }
Example #24
0
        public static void Initialize(JobsContext jobsApplied)
        {
            jobsApplied.Database.EnsureCreated();

            if (jobsApplied.JobsModel.Any())
            {
                return;
            }

            var jobs = new JobsModel
            {
                ID           = 1, company = "Amazon", title = "Software Engineer", job_number = "000001",
                last_checked = DateTime.Parse("2020-05-01"), last_updated = DateTime.Parse("2020-04-01"),
                date_applied = DateTime.Parse("2020-03-01"), status = "Active", notes = "Still Active",
                interview    = true, rejected = false, city = "Seattle", state = "Washington",
                country      = "United States"
            };

            jobsApplied.JobsModel.AddRange(jobs);
            jobsApplied.SaveChanges();
        }
Example #25
0
        public void GetJobsToRun_ReturnsJobs()
        {
            var dateTimeOffset     = new DateTimeOffset(DateTime.Today);
            var fromDateTimeOffset = dateTimeOffset.AddHours(-2);
            var toDateTimeOffset   = dateTimeOffset.AddHours(4).AddMilliseconds(-1);

            var jobsContext = new JobsContext();

            foreach (var jobItem in new[]
            {
                Midnight,
                EverydayAt0_OClock,
                EverydayAt4_OClock
            })
            {
                jobsContext.JobItems.Add(jobItem);
            }

            var jobStorageItems = jobsContext.GetJobsToRun(fromDateTimeOffset, toDateTimeOffset);

            Assert.Equal(3, jobsContext.JobItems.Count);
            Assert.Equal(2, jobStorageItems.Length);
        }
Example #26
0
        public static bool PostJob(JobDetailsModel model)
        {
            var post = JobsContext.PostJob(new JobDetail()
            {
                job_details_id   = model.Job_details_id,
                job_organization = model.Job_organization,
                job_img          = "",
                employee_id      = RegistrationProvider.GetUseridfromUsername(model.username),
                job_date         = model.Job_date,
                job_applied_date = DateTime.Now,
                job_description  = model.Job_description,
                job_title        = model.Job_title,
                jo_date_modified = DateTime.Now,
                job_city         = model.Job_city,
                job_type         = model.Job_type
            });

            if (post > 0)
            {
                return(true);
            }
            return(false);
        }
Example #27
0
        public User Authenticate(string username, string password)
        {
            User user = null;

            using (var db = new JobsContext())
            {
                user =
                    db.Users.SingleOrDefault(x => x.Username == username && x.Password == password);

                if (user == null)
                {
                    return(null);
                }
            }

            // authentication successful so generate jwt token
            var tokenHandler    = new JwtSecurityTokenHandler();
            var key             = Encoding.ASCII.GetBytes(_appSettings.Secret);
            var tokenDescriptor = new SecurityTokenDescriptor
            {
                Subject = new ClaimsIdentity(new Claim[]
                {
                    new Claim(ClaimTypes.Name, user.Id.ToString())
                }),
                Expires            = DateTime.UtcNow.AddDays(7),
                SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key),
                                                            SecurityAlgorithms.HmacSha256Signature)
            };
            var token = tokenHandler.CreateToken(tokenDescriptor);

            user.Token = tokenHandler.WriteToken(token);

            user.Password = null;

            return(user);
        }
Example #28
0
 public JobAidController(JobsContext JobsContext, AuthenticationController AuthenticationController)
 {
     this.JobsContext = JobsContext;
     this.AuthenticationController = AuthenticationController;
 }
 public CategoryController(JobsContext db)
 {
     this.db = db;
 }
Example #30
0
 public ValuesController(JobsContext db)
 {
     this.db = db;
 }
Example #31
0
 public PluginConfig(JobsContext jobsContext)
 {
     _jobsContext = jobsContext;
 }