Beispiel #1
0
        public async Task <IActionResult> Edit(Guid?id, [Bind("JobApplicationId,DateApplied,ApplicationStatus,PersonId,JobId")] JobApplications jobApplications)
        {
            if (id != jobApplications.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(jobApplications);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!JobApplicationsExists(jobApplications.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["JobId"] = new SelectList(_context.Jobs, "JobId", "JobId", jobApplications.JobId);
            return(PartialView(jobApplications));
        }
Beispiel #2
0
        // GET: Jobs/Details/5
        public ActionResult Details(int id)
        {
            int        userid = 0;
            HttpCookie jobId  = new HttpCookie("JobId");

            jobId["JobId"] = id.ToString();
            Response.Cookies.Add(jobId);
            HttpCookie reqCookies = Request.Cookies["userInfo"];

            if (reqCookies != null)
            {
                string Position       = db.Jobs.Where(x => x.Id == id).FirstOrDefault().Position;
                string FullPart       = db.Jobs.Where(x => x.Id == id).FirstOrDefault().FullPart;
                string Description    = db.Jobs.Where(x => x.Id == id).FirstOrDefault().Description;
                string Qualifications = db.Jobs.Where(x => x.Id == id).FirstOrDefault().Qualifications;
                string Company        = db.Jobs.Where(x => x.Id == id).FirstOrDefault().Company;
                int    Salary         = Convert.ToInt32(db.Jobs.Where(x => x.Id == id).FirstOrDefault().Salary);
                userid = Convert.ToInt32(reqCookies["Id"].ToString());
                List <AppliesFor> appliesfor   = db.AppliesFors.ToList();
                List <int>        Applications = new List <int>();
                foreach (AppliesFor a in appliesfor)
                {
                    if (a.JobId == id)
                    {
                        Applications.Add(a.Profileid);
                    }
                }
                JobApplications model = new JobApplications(id, Position, FullPart, Description, Qualifications, Applications, Company, Salary);
                return(View(model));
            }
            return(View());
        }
Beispiel #3
0
        public async Task <IActionResult> Apply(long id)
        {
            //Get current user details
            var user = await _lookUpService.GetCurrentLoggedInUser(User.Identity.Name);

            //Get currect leaner details
            var learner = await _lookUpService.GetLearnerDetailsByIdEmail(user.Email);

            if (ModelState.IsValid)
            {
                //Prepare and application
                var jobApplications = new JobApplications
                {
                    ApplicationStatus = Const.PENDINNG_STATUS,
                    DateApplied       = DateTime.Now,
                    LearnerId         = learner.LearnerId,
                    JobId             = id,
                };

                var lnr = _context.Learner.FirstOrDefault(l => l.LearnerId == learner.LearnerId);
                lnr.AppliedYn = Const.TRUE;

                await SendAcknowledgementMail(learner);

                _context.Update(lnr);
                _context.Add(jobApplications);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(RedirectToAction("Details", "Person", new { id = learner.NationalID }));
        }
        public string PostJobApplications([FromBody] JobApplications jobApplication)
        {
            var  allQuestions   = _context.Questions.ToList();
            bool AcceptOrReject = jobApplication.Questions.All(jaa =>
                                                               allQuestions.FirstOrDefault(q => q.QuestionId == jaa.QuestionId)?.Answer == jaa.Answer);

            _context.JobApplications.Add(jobApplication);
            _context.SaveChangesAsync();

            return(AcceptOrReject ? "Accept" : "Reject");
        }
        public async Task <IActionResult> IndexPost(SchedulesViewModel model)
        {
            List <Schedules>   allschedules   = new List <Schedules>();
            JobApplications    jobAppModel    = new JobApplications();
            Candidate          candidateModel = new Candidate();
            SchedulesViewModel latestRecord   = new SchedulesViewModel();

            try
            {
                //for getting the job application of candidate in current scenario (we are in schedules so for getting
                //job Application ID, need to go through candidate)
                candidateModel = _dbContext.Candidate.Where(x => x.ID == model.candidateId).FirstOrDefault();
                jobAppModel    = _dbContext.jobApplications.Where(x => x.candidateId == model.candidateId).FirstOrDefault();

                //checking for already existing round
                allschedules = _dbContext.Schedules.Where(x => x.candidateId == model.candidateId).ToList();
                foreach (var item in allschedules)
                {
                    if (item.round == model.round)
                    {
                        TempData["msg"] = model.round;
                        return(RedirectToAction("Details", "JobApplication", new { id = jobAppModel.ID, conflict = TempData["msg"] }));
                    }
                }
                //for new schedule Proceed
                //converting enum values to int
                model.status = Convert.ToInt32(model.statusvalue);

                //saving all the interviewers
                List <string> interviewers = new List <string>();
                interviewers = model.Multiinterviewer;

                //fetch schedule from db for this candidate , getting schedule id for composite key use.
                latestRecord = await _schedulesPage.AddNewSchedules(model);

                //insert Composite keys to SchedulesUsers (interviewers to schedules mapping)
                foreach (var item in interviewers)
                {
                    SchedulesUsersViewModel newModel = new SchedulesUsersViewModel()
                    {
                        scheduleId = latestRecord.ID,
                        UserId     = item
                    };
                    await _schedulesUsersPage.AddNewSchedulesUsers(newModel);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return(RedirectToAction("Details", "JobApplication", new { id = jobAppModel.ID }));
        }
Beispiel #6
0
        public async Task <IActionResult> Create([Bind("JobApplicationId,DateApplied,ApplicationStatus,PersonId,JobId")] JobApplications jobApplications)
        {
            if (ModelState.IsValid)
            {
                _context.Add(jobApplications);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }


            ViewData["JobId"] = new SelectList(_context.Jobs, "JobId", "JobId", jobApplications.JobId);

            return(PartialView(jobApplications));
        }
Beispiel #7
0
        public async Task <IActionResult> UpdateScheduleOfJobApplicationPost(SchedulesViewModel model)
        {
            List <SchedulesUsers> collection     = new List <SchedulesUsers>();
            List <string>         interviewers   = new List <string>();
            JobApplications       jobApplication = new JobApplications();

            try
            {
                //converting enum values to int
                model.status = Convert.ToInt32(model.statusvalue);

                //saving all the interviewers
                interviewers = model.Multiinterviewer;

                //all data of ScheduleUser composite table
                collection = _dbContext.SchedulesUsers.Where(x => x.scheduleId == model.ID).ToList();

                //removing the existing pairs of old schedules interviewers
                _dbContext.SchedulesUsers.RemoveRange(collection);
                _dbContext.SaveChanges();

                //adding new records of composite key into schedule users for new userschedule pairs
                foreach (var item in interviewers)
                {
                    SchedulesUsersViewModel newModel = new SchedulesUsersViewModel()
                    {
                        scheduleId = model.ID,
                        UserId     = item
                    };
                    await _schedulesUsersPage.AddNewSchedulesUsers(newModel);
                }

                await _schedulesPage.UpdateSchedule(model);

                //redirecting to details of job Application
                jobApplication = _dbContext.jobApplications.Where(x => x.candidateId == model.candidateId).FirstOrDefault();
            }catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return(RedirectToAction("Details", "JobApplication", new { id = jobApplication.ID }));
        }
Beispiel #8
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public int[] applyToJobs()
        {
            foreach (Job job in JobApplications)
            {
                //TODO: Get rid  of this print after debugging
                job.printJob();

                string result = applyToJob(job.Link);
                if (result == "success")
                {
                    CompletedLinks.Add(job.Link);
                }
                else
                {
                    ErrorLinks.Add(job.Link);
                }
                JobApplications.Remove(job);
            }
            return(new int[] { CompletedLinks.Count, ErrorLinks.Count });
        }
        //GET: Function to get the specific Job details.
        public ActionResult ShowJob(int id)
        {
            Debug.WriteLine("Entering Show Job");
            Debug.WriteLine("Entered Job ID is:" + id);

            //This query gets the job with the specified jobId
            string query = "select * from Jobs where JobId = @JobId";
            Job    job   = db.Jobs.SqlQuery(query, new SqlParameter("@JobId", id)).FirstOrDefault();

            //Query to get the list of applications. This will not be displayed for the User.
            query = "select * from Applications where JobId = @JobId";
            List <Application> applications = db.Applications.SqlQuery(query, new SqlParameter("@JobId", job.jobId)).ToList();

            //Adding the above queries to the viewmodel
            JobApplications jobApplications = new JobApplications();

            jobApplications.job = job;
            jobApplications.applicantionList = applications;

            //Returning the ShowJobPost ViewModel object to the ShowJob view.
            return(View(jobApplications));
        }
        //GET: Function to get the specific Job deatils and Show the List of applications for that job. This is for the Admin.
        public ActionResult ShowJobAdmin(int id)
        {
            Debug.WriteLine("Entering Show Job");
            Debug.WriteLine("Entered Job ID is:" + id);

            //This query gets the job with the specified jobId
            string query = "select * from Jobs where JobId = @JobId";
            Job    job   = db.Jobs.SqlQuery(query, new SqlParameter("@JobId", id)).FirstOrDefault();

            //This query is used to get the list of applications that have been done for the specific job.
            query = "select * from Applications where JobId = @JobId";
            List <Application> applications = db.Applications.SqlQuery(query, new SqlParameter("@JobId", job.jobId)).ToList();

            //The below View Model is used to store the Job Details and the list of applications that have been made for the specific job.
            JobApplications jobApplications = new JobApplications();

            jobApplications.job = job;
            jobApplications.applicantionList = applications;

            //Returning the JobApplications ViewModel object to the Show Job Admin view.
            return(View(jobApplications));
        }
        public IActionResult Apply(int id)
        {
            int userId = -1;

            if (int.TryParse(HttpContext.Session.GetString("UserId"), out userId) && int.TryParse(HttpContext.Session.GetString("Role"), out int roleId) && roleId == 2)
            {
                using (var db = new jobsDBContext())
                {
                    var jobapp = new JobApplications
                    {
                        JobPostingId = id,
                        ApplicantId  = userId,
                    };
                    db.JobApplications.Add(jobapp);
                    db.SaveChanges();
                    return(View());
                }
            }
            else
            {
                return(RedirectToAction("Login"));
            }
        }