Esempio n. 1
0
        /// <inheritdoc />
        protected override IEnumerator OnExecute(JobContext context)
        {
            BaseField variable;

            if (!context.TryGetField(VariableName, out variable))
            {
                if (CreateNew)
                {
                    variable = Field <string> .Create(VariableName, NewValue);

                    context.Add(variable);
                }
                else
                {
                    IsSuccess = false;
                    RockLog.WriteLine(this, LogTier.Error, string.Format("Couldn't find variable of name: {0}", VariableName));
                    yield break;
                }
            }

            variable.SetValue(NewValue);

            IsSuccess = true;
            yield return(null);
        }
Esempio n. 2
0
        public IActionResult RegisterUser(RegisterUser newuser)
        {
            User CheckEmail = _iContext.users
                              .Where(u => u.email == newuser.email)
                              .SingleOrDefault();

            if (CheckEmail != null)
            {
                ViewBag.errors = "That email already exists";
                return(RedirectToAction("Register"));
            }
            if (ModelState.IsValid)
            {
                PasswordHasher <RegisterUser> Hasher = new PasswordHasher <RegisterUser>();
                User newUser = new User
                {
                    user_id  = newuser.user_id,
                    name     = newuser.name,
                    email    = newuser.email,
                    username = newuser.username,
                    password = Hasher.HashPassword(newuser, newuser.password)
                };
                _iContext.Add(newUser);
                _iContext.SaveChanges();
                return(RedirectToAction(""));
            }
            else
            {
                return(View("Register"));
            }
        }
Esempio n. 3
0
        public async Task <IActionResult> NewJob(job job)
        {
            job.Id = 0;
            _context.Add(job);
            await _context.SaveChangesAsync();

            return(Ok("innformation is saved"));
        }
        private static JobContext GetSeededJobContext(Job job, JobExecution jobExecution)
        {
            var contextOptions = new DbContextOptionsBuilder <JobContext>()
                                 .UseInMemoryDatabase("test")
                                 .ConfigureWarnings(w => w.Ignore(InMemoryEventId.TransactionIgnoredWarning))
                                 .Options;

            var context = new JobContext(contextOptions);

            context.Database.EnsureDeleted();
            context.Database.EnsureCreated();

            context.Add(job);
            context.Add(jobExecution);

            context.SaveChanges();

            return(context);
        }
Esempio n. 5
0
    public async Task <IActionResult> Create([Bind("ID,EmployerName,JobTitle,StartDate,StopDate,JobDescription")] Job job)
    {
        if (ModelState.IsValid)
        {
            _context.Add(job);
            await _context.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
        return(View(job));
    }
        public async Task <IActionResult> Create([Bind("Id,Name,Description")] Department department)
        {
            if (ModelState.IsValid)
            {
                _context.Add(department);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(department));
        }
Esempio n. 7
0
        public async Task <IActionResult> Create([Bind("JobID,Title,Description,Job_Number,Date_Applied")] Job job)
        {
            if (ModelState.IsValid)
            {
                _context.Add(job);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(job));
        }
        public async Task <IActionResult> Create([Bind("TypeName,ID")] EmploymentStatus employmentStatus)
        {
            if (ModelState.IsValid)
            {
                employmentStatus.ID = Guid.NewGuid();
                _context.Add(employmentStatus);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(employmentStatus));
        }
        public async Task <IActionResult> Create([Bind("CategoryName,ID")] JobCategory jobCategory)
        {
            if (ModelState.IsValid)
            {
                jobCategory.ID = Guid.NewGuid();
                _context.Add(jobCategory);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(jobCategory));
        }
Esempio n. 10
0
        public async Task <IActionResult> Create([Bind("JobTitle,JobDescription,JobResponsibility,EducationDetails,Salary,AgeLimit,TagID,CategoryID,EmploymentStatusID,LastDate,ID")] Job job)
        {
            if (ModelState.IsValid)
            {
                job.ID = Guid.NewGuid();
                _context.Add(job);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EmploymentStatusID"] = new SelectList(_context.EmploymentStatus, "ID", "TypeName", job.EmploymentStatusID);
            ViewData["CategoryID"]         = new SelectList(_context.JobCategory, "ID", "CategoryName", job.CategoryID);
            ViewData["TagID"] = new SelectList(_context.JobTag, "ID", "TagName", job.TagID);
            return(View(job));
        }
Esempio n. 11
0
        public async Task <IActionResult> Create([Bind("JobTitle,Description,CreatedAt,ExpiresAt,Id")] Job job)
        {
            if (ModelState.IsValid)
            {
                // Gets default expiration days
                var Config = from cc in _context.Configurations
                             where cc.Id == ACTIVE_DAYS
                             select cc;
                var conf = Config.FirstOrDefault();
                int days = (conf == null) ? 30 : int.Parse(conf.Value);

                job.Id        = Guid.NewGuid().ToString();
                job.CreatedAt = DateTime.Today;
                job.ExpiresAt = job.CreatedAt.Add(new System.TimeSpan(days, 0, 0, 0));

                _context.Add(job);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(job));
        }
Esempio n. 12
0
        public async Task <IActionResult> Apply(int id, [Bind("PrefDateToJoin,FormFile")] BinderModel binderModel, ICollection <Education> Input)
        {
            var jobPost = await _context.JobPosts.FindAsync(id);

            if (jobPost == null || jobPost.Status == JobPostStatus.Closed)
            {
                return(NotFound());
            }

            var user = await _userManager.GetUserAsync(User);

            if (user == null)
            {
                return(NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'."));
            }

            if (((Candidate)user).JobApplications.Any(J => J.JobPostId == jobPost.Id))
            {
                TempData["AppMessage"] = "You have already applied.";
                return(RedirectToAction(nameof(Details), new { id = jobPost.Id }));
            }



            bool cvUploaded = (binderModel.FormFile != null);

            if (!cvUploaded && ((Candidate)user).CV == null)
            {
                //binderModel.StatusMessage = "You must provide cv to apply.";
                ModelState.AddModelError("CV", "You must provide cv to apply.");
                binderModel = new BinderModel();
                await LoadAsync(user, binderModel);

                //TempData["StatusMessage"] = "You must provide cv to apply.";
                return(View(binderModel));
            }
            byte[] Content = new byte[0];

            if (cvUploaded)
            {
                using (var memoryStream = new MemoryStream())
                {
                    await binderModel.FormFile.CopyToAsync(memoryStream);

                    // Upload the file if less than 2 MB
                    if (memoryStream.Length < 2097152 * 4)
                    {
                        Content = memoryStream.ToArray();
                    }
                    else
                    {
                        ModelState.AddModelError("File", "The file is too large.");
                    }
                }
            }

            if (!ModelState.IsValid)
            {
                binderModel = new BinderModel();
                await LoadAsync(user, binderModel);

                return(View(binderModel));
            }

            var cnt = ((Candidate)user).Educations.Count;

            ((Candidate)user).Educations = Input;

            if (cvUploaded)
            {
                CV cv = new CV();
                cv.Title     = binderModel.FormFile.FileName;
                cv.Content   = Content;
                cv.Extension = Path.GetExtension(binderModel.FormFile.FileName);
                if (cv.Extension.Length > 20)
                {
                    cv.Extension = "unknown";
                }
                ((Candidate)user).CV = cv;
            }

            var updt = await _userManager.UpdateAsync(user);

            if (!updt.Succeeded)
            {
                TempData["AppMessage"] = "Unexpected error when trying to update educations.";
                //binderModel.StatusMessage = "Unexpected error when trying to update educations.";
                return(RedirectToAction());
            }


            var newApp = new JobApplication()
            {
                JobPostId      = jobPost.Id,
                CandidateId    = user.Id,
                CV             = ((Candidate)user).CV,
                AppStatus      = AppStatus.AppReceived,
                PrefDateToJoin = (DateTime)binderModel.PrefDateToJoin,
                AppDate        = DateTime.Now
            };

            _context.Add(newApp);
            await _context.SaveChangesAsync();

            TempData["AppMessage"] = "We Have Received Your Application.";
            return(RedirectToAction(nameof(Details), new { id = jobPost.Id }));
        }