Esempio n. 1
0
        public ActionResult Create([Bind(Include = "ApplicationID,CandidateID,JobID,DateApplied")] Application application)
        {
            if (ModelState.IsValid)
            {
                db.Applications.Add(application);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CandidateID = new SelectList(db.Candidates, "CandidateID", "FirstName", application.CandidateID);
            ViewBag.JobID       = new SelectList(db.Jobs, "JobID", "Job_Title", application.JobID);
            return(View(application));
        }
Esempio n. 2
0
        public ActionResult Create([Bind(Include = "QualificationId,QualificationType,QualificationName,DateStarted,DateCompleted,CandidateId")] Qualification qualification
                                   , string save, string addMore)
        {
            if (ModelState.IsValid)
            {
                // if no qualification is entered, redirect to search page
                if ((qualification.QualificationType == null) &&
                    (qualification.QualificationName == "" || qualification.QualificationType == null))
                {
                    return(RedirectToAction("Index", "Candidates"));
                }

                //else save qualification
                db.Qualifications.Add(qualification);
                db.SaveChanges();

                //choose to save and complete creating candidate
                if (!string.IsNullOrEmpty(save))
                {
                    return(RedirectToAction("Index", "Candidates"));
                }
                //choose to add more qualification to the same candidate
                if (!string.IsNullOrEmpty(addMore))
                {
                    TempData["Message"] = "Qualification Saved";
                    return(RedirectToAction("Create", "Qualifications", new { id = qualification.CandidateId }));
                }
            }

            //fail to save, refresh page with the same candidate
            ViewBag.CandidateId = qualification.CandidateId;
            return(View(qualification));
        }
Esempio n. 3
0
        private void SaveCandidatesAndConversations()
        {
            List <Conversation> conversations = new List <Conversation>();
            List <V>            candidates    = new List <V>();

            foreach (var model in _model)
            {
                model.BuildModel();
                var conv      = _mapper.Map <Conversation>(model);
                var candidate = _mapper.Map <V>(model);

                if (!String.IsNullOrWhiteSpace(conv.ChatLog))
                {
                    conversations.Add(conv);
                }

                if (model.CheckIfCandidateExists(_context) && !String.IsNullOrWhiteSpace(model.Name))
                {
                    candidates.Add(candidate);
                }
            }
            _context.Conversations.AddRange(conversations);
            _model.FirstOrDefault().Save <V>(_context, candidates);
            _context.SaveChanges();
        }
Esempio n. 4
0
        public IActionResult Create([FromBody] Candidate item)
        {
            if (item == null)
            {
                return(BadRequest());
            }
            if (string.IsNullOrEmpty(item.Id.ToString()))
            {
                _context.Candidates.Add(item);
                _context.SaveChanges();

                return(CreatedAtRoute("GetTodo", new { id = item.Id }, item));
            }
            else
            {
                return(Update(item.Id, item));
            }
        }
Esempio n. 5
0
        public ActionResult <object> CreateGeek(CandidateViewModel candidateViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Candidate candidate = new Candidate {
                FirstName = candidateViewModel.FirstName,
                LastName  = candidateViewModel.LastName
            };

            _context.Candidate.Add(candidate);
            _context.SaveChanges(); // to let candidate have Id.

            List <SkillMap> maps = new List <SkillMap>();

            foreach (var name in candidateViewModel.Skills)
            {
                Skill skill = _context.Skill.Single(item => item.Name == name);
                maps.Add(new SkillMap {
                    CandidateId = candidate.Id, SkillId = skill.Id
                });
            }

            _context.SkillMap.AddRange(maps);
            _context.SaveChanges();

            // prepare result.
            List <string> skills = new List <string>();

            foreach (var map in candidate.Skills)
            {
                skills.Add(map.Skill.Name);
            }

            return(new {
                candidate.Id,
                candidate.FirstName,
                candidate.LastName,
                skills,
            });
        }
Esempio n. 6
0
        public ActionResult Create([Bind(Include = "ID,Name,Email,Mobile,CallbackDetail,CreateOn,UpdateOn,Pin,Active,CityCode,StateCode")] Candidate candidate)
        {
            if (ModelState.IsValid)
            {
                db.Candidates.Add(candidate);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(candidate));
        }
Esempio n. 7
0
        public CandidatesController(CandidateContext context)
        {
            _context = context;

            if (_context.Candidates.Count() == 0)
            {
                _context.Candidates.Add(new Candidate {
                    Name = "Item1"
                });
                _context.SaveChanges();
            }
        }
        public static void Initialize(CandidateContext candidateContext)
        {
            candidateContext.Database.EnsureCreated();

            if (candidateContext.Candidates.Any())
            {
                candidateContext.RemoveRange(candidateContext.Candidates);
                candidateContext.RemoveRange(candidateContext.Resumes);
            }

            Resume resume = new Resume {
                FirstName = "John", LastName = "Doe", ResumeText = "Test Job"
            };

            Candidate candidate = new Candidate {
                FirstName = "John", LastName = "Doe", YearsExperience = 0, City = "Atlanta", State = "GA", Resumes = new List <Resume>()
            };

            candidateContext.Add <Candidate>(candidate);
            candidateContext.SaveChanges();
            candidate.Resumes.Add(resume);
            candidateContext.SaveChanges();
        }
Esempio n. 9
0
        public ActionResult Create([Bind(Include = "CandidateId,FirstName,LastName,PhoneNumber,Email,ZipCode")] Candidate candidate)
        {
            //save candidate information then proceed to add qualification page
            if (ModelState.IsValid)
            {
                db.Candidates.Add(candidate);
                try
                {
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    TempData["Message"] = "Duplicate phone number or email!";
                    return(View(candidate));
                }
                return(RedirectToAction("Create", "Qualifications", new { id = candidate.CandidateId }));
            }

            return(View(candidate));
        }
Esempio n. 10
0
        public void Post(int candidateId, string resumeFormat, [FromBody] byte[] resumeRaw)
        {
            Candidate candidate = _candidateContext.Candidates
                                  .Where(c => c.CandidateId == candidateId)
                                  .FirstOrDefault();

            if (candidate == null)
            {
                return;
            }

            Bitmap bmp;
            var    ocrText = string.Empty;

            using (var ms = new MemoryStream(resumeRaw))
            {
                bmp = new Bitmap(ms);
                var ocr = new TesseractEngine(Properties.Resources.TesseractData, "eng", EngineMode.Default);
                using (var img = PixConverter.ToPix(bmp))
                {
                    using (var page = ocr.Process(img))
                    {
                        ocrText = page.GetText();
                    }
                }
                if (ocrText != null)
                {
                    candidate.Resumes.Add(new Resume {
                        FirstName = candidate.FirstName, LastName = candidate.LastName, ResumeText = ocrText
                    });
                }
                else
                {
                    candidate.Resumes.Add(new Resume {
                        FirstName = candidate.FirstName, LastName = candidate.LastName, ResumeRaw = resumeRaw
                    });
                }
            }

            _candidateContext.SaveChanges();
        }
Esempio n. 11
0
        public void VoteForCandidate(RequestVoterModel voter)
        {
            var candidate = _context.Candidates
                            .Where(el => el.Id == voter.CandidateID)
                            .Select(el => new
            {
                IdCandidate = el.Id
            })
                            .FirstOrDefault();

            var isnNewUserExist = _context.Users.Any(p => p.UserPesel == voter.UserPesel);

            if (!isnNewUserExist && candidate != null)
            {
                _context.Users.Add(new User()
                {
                    CandidatesId = candidate.IdCandidate,
                    UserPesel    = voter.UserPesel,
                });

                _context.SaveChanges();
            }
        }
 public void Post([FromBody] Candidate candidate)
 {
     _candidateContext.Add <Candidate>(candidate);
     _candidateContext.SaveChanges();
 }