public ActionResult AddCandidateSkills(CandidateSkill cs) { ViewBag.SkillId = new SelectList(db.Skills, "Id", "SkillName", cs.SkillId); ViewBag.SkillExperienceId = new SelectList(db.SkillExperiences, "Id", "Experience", cs.Experience); string id = User.Identity.GetUserId(); cs.UserId = id; if (ModelState.IsValid) { if (cs.Id > 0) { db.Entry(cs).State = EntityState.Modified; db.SaveChanges(); } else { db.CandidateSkills.Add(cs); db.SaveChanges(); } } else { var errors = ModelState.Select(x => x.Value.Errors) .Where(y => y.Count > 0) .ToList(); } return(View(cs)); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { JObject jObject = JObject.Load(reader); CandidatesResponse res = new CandidatesResponse(); res.Name = (string)jObject["name"]; res.LastName = (string)jObject["lastName"]; res.DNI = (int)jObject["dni"]; res.EmailAddress = (string)jObject["emailAddress"]; res.PhoneNumber = (string)jObject["phoneNumber"]; res.LinkedInProfile = (string)jObject["linkedInProfile"]; res.AdditionalInformation = (string)jObject["additionalInformation"]; res.EnglishLevel = (EnglishLevel)(int)jObject["englishLevel"]; res.Status = (CandidateStatus)(int)jObject["status"]; res.ContactDay = DateTime.Parse((string)jObject["contactDay"]); List <CandidateSkill> CandidateSkillsList = new List <CandidateSkill>(); JArray candidates = (JArray)jObject["candidateSkills"]; if (candidates != null) { foreach (var item in candidates) { var singleCandidateSkill = new CandidateSkill(); singleCandidateSkill.CandidateId = (int)item["candidateId"]; singleCandidateSkill.SkillId = (int)item["skillId"]; singleCandidateSkill.Rate = (int)item["rate"]; singleCandidateSkill.Comment = (string)item["comment"]; CandidateSkillsList.Add(singleCandidateSkill); } } res.CandidateSkills = CandidateSkillsList; return(res); }
public ActionResult DeleteConfirmed(long id) { CandidateSkill candidateSkill = db.CandidateSkills.Find(id); db.CandidateSkills.Remove(candidateSkill); db.SaveChanges(); return(RedirectToAction("Index", new { candidateId = candidateSkill.CandidateId })); }
public ActionResult DeleteConfirmed(int RecordID) { CandidateSkill CandidateSkill = db.CandidateSkill.Find(RecordID); db.CandidateSkill.Remove(CandidateSkill); db.SaveChanges(); return(RedirectToAction("Index", "CandidatePersonalInfProfile")); }
public HttpResponseMessage Post([FromBody] CandidateSkill skill) { _candidateSkillService.Add(skill); var message = Request.CreateResponse(HttpStatusCode.Created); message.Headers.Location = new Uri(Request.RequestUri + skill.Id.ToString()); return(message); }
public ActionResult EditingSkill_Create(CandidateSkill obj) { new Skill().Insert(SessionItems.CurrentUser.Id, obj); Resume resume = Session[typeof(Resume).FullName] as Resume; resume.Skills.Add(obj); Session[typeof(Resume).FullName] = resume; return(Json(true, JsonRequestBehavior.AllowGet)); }
public IActionResult PostCandidateSkill([FromBody] CandidateSkill candidateSkill) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } candidateSkill.Id = _candidateSkillsRepository.AddCandidateSkill(candidateSkill); return(CreatedAtAction("PostCandidateSkill", new { id = candidateSkill.Id }, candidateSkill)); }
public IActionResult PutCandidateSkill([FromBody] CandidateSkill candidateSkill) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _candidateSkillsRepository.EditCandidateSkill(candidateSkill); return(Ok(candidateSkill)); }
public ActionResult Edit([Bind(Include = "Id,CandidateId,SkillId")] CandidateSkill candidateSkill) { if (ModelState.IsValid) { db.Entry(candidateSkill).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CandidateId = new SelectList(db.Candidates, "Id", "FirstName", candidateSkill.CandidateId); ViewBag.SkillId = new SelectList(db.Skills, "Id", "Name", candidateSkill.SkillId); return(View(candidateSkill)); }
public ActionResult Edit([Bind(Include = "RecordID,UserID,Skill,Competency,Experience")] CandidateSkill CandidateSkill) { CandidateSkill.UserID = User.Identity.GetUserId(); CandidateSkill.UpdateDate = DateTime.Now; if (ModelState.IsValid) { db.Entry(CandidateSkill).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", "CandidatePersonalInfProfile")); } return(View(CandidateSkill)); }
public ActionResult EditingSkill_Destroy(CandidateSkill obj) { new Skill().Delete(obj); Resume resume = Session[typeof(Resume).FullName] as Resume; if (resume.Skills.Any(x => x.Id.Equals(obj.Id))) { int idx = resume.Skills.Select((v, i) => new { objt = v, index = i }).FirstOrDefault(x => x.objt.Id.Equals(obj.Id)).index; resume.Skills.RemoveAt(idx); } Session[typeof(Resume).FullName] = resume; return(Json(true, JsonRequestBehavior.AllowGet)); }
public async Task AddSkill(CandidateSkill model) { var entry = _context.CandidateSkills.FirstOrDefault(p => p.CandidateId == model.CandidateId && p.SkillId == model.SkillId); if (entry == null) { await _context.CandidateSkills.AddAsync(model); } else { _context.CandidateSkills.Remove(entry); } await _context.SaveChangesAsync(); }
// GET: Skills/Details/5 public ActionResult Details(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CandidateSkill candidateSkill = db.CandidateSkills.Find(id); if (candidateSkill == null) { return(HttpNotFound()); } return(View(candidateSkill)); }
// GET: CandidateSkill/Details/5 public ActionResult Details(int?CompetencyID) { if (CompetencyID == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CandidateSkill CandidateSkill = db.CandidateSkill.Find(CompetencyID); if (CandidateSkill == null) { return(RedirectToAction("Index", "CandidatePersonalInfProfile")); } return(View(CandidateSkill)); }
// GET: Skills/Delete/5 public ActionResult Delete(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CandidateSkill candidateSkill = db.CandidateSkills.Find(id); if (candidateSkill == null) { return(HttpNotFound()); } return(RedirectToAction("Index", new { candidateId = candidateSkill.CandidateId })); }
public async Task <CandidateModel> GetBestMatchedCandidateAsync(int JobId) { List <CandidateModel> CandidateList = await _candidateAPIContext.GetAsync <List <CandidateModel> >(); List <JobModel> JobList = await _jobAPIContext.GetAsync <List <JobModel> >(); List <(int CandidateID, int Points)> Points = new List <(int CandidateID, int Points)>(); var Job = JobList?.Where(x => x.jobId == JobId).FirstOrDefault(); if (Job is null) { return(null); } int CandidatePoints = 0; foreach (var candidate in CandidateList) { int CandidateSkillsCount = candidate.skillTagsList.Count; int JobSkillsCount = Job.skillsList.Count; foreach (string CandidateSkill in candidate.skillTagsList) { foreach (string JobSkill in Job.skillsList) { if (CandidateSkill.Trim().ToUpper() == JobSkill.Trim().ToUpper()) { CandidatePoints += JobSkillsCount * CandidateSkillsCount; } JobSkillsCount -= 1; } CandidateSkillsCount -= 1; } Points.Add((candidate.candidateId, CandidatePoints)); CandidatePoints = 0; } int MaxPointOfCandidates = Points.Max(c => c.Points); var BestCandidateMatch = Points.Where(c => c.Points == MaxPointOfCandidates).FirstOrDefault(); var BestCandidateDetails = CandidateList.Where(c => c.candidateId == BestCandidateMatch.CandidateID).FirstOrDefault(); return(BestCandidateDetails); }
// GET: CandidateSkill/Edit/5 public ActionResult Edit(int?RecordID) { ViewBag.Competency = new SelectList(db.Competency, "CompetencyID", "Competency1"); if (RecordID == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CandidateSkill CandidateSkill = db.CandidateSkill.Find(RecordID); if (CandidateSkill == null) { return(RedirectToAction("Index", "CandidatePersonalInfProfile")); } return(View(CandidateSkill)); }
public ActionResult Create([Bind(Include = "RecordID,Skill,Competency,Experience")] CandidateSkill CandidateSkill) { ViewBag.Competency = new SelectList(db.Competency, "CompetencyID", "Competency1"); CandidateSkill.UpdateDate = DateTime.Now; CandidateSkill.UserID = User.Identity.GetUserId(); if (ModelState.IsValid) { db.CandidateSkill.Add(CandidateSkill); db.SaveChanges(); return(RedirectToAction("Index", "CandidatePersonalInfProfile")); } return(View(CandidateSkill)); }
// GET: Skills/Edit/5 public ActionResult Edit(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CandidateSkill candidateSkill = db.CandidateSkills.Find(id); if (candidateSkill == null) { return(HttpNotFound()); } ViewBag.CandidateId = new SelectList(db.Candidates, "Id", "FirstName", candidateSkill.CandidateId); ViewBag.SkillId = new SelectList(db.Skills, "Id", "Name", candidateSkill.SkillId); return(View(candidateSkill)); }
public ActionResult Create([Bind(Include = "Id,CandidateId,SkillId")] CandidateSkill candidateSkill) { if (ModelState.IsValid) { //candidateSkill.Candidate = db.Candidates.Where(x => x.Id == candidateSkill.CandidateId).Single(); //candidateSkill.Skill = db.Skills.Where(x => x.Id == candidateSkill.SkillId).Single(); //candidateSkill.Id = 0; db.CandidateSkills.Add(candidateSkill); db.SaveChanges(); return(RedirectToAction("Index", new { candidateId = candidateSkill.CandidateId })); } ViewBag.CandidateId = new SelectList(db.Candidates, "Id", "FirstName", candidateSkill.CandidateId); ViewBag.SkillId = new SelectList(db.Skills, "Id", "Name", candidateSkill.SkillId); return(View(candidateSkill)); }
public ResultModel Delete(CandidateSkill obj) { try { CandidateSkill objt = DataContext.CandidateSkills.Where(x => x.Id.Equals(obj.Id)).FirstOrDefault(); if (objt != null && !objt.Id.Equals(Guid.Empty)) { DataContext.CandidateSkills.DeleteOnSubmit(objt); DataContext.SubmitChanges(); } return(ResultModel.SuccessResult()); } catch (Exception e) { Console.WriteLine(e); // Provide for exceptions. return(ResultModel.FailResult()); } }
public ResultModel Insert(string userId, CandidateSkill obj) { CandidateSkill objt = new CandidateSkill(); LoadModel(obj, objt); objt.Id = Guid.NewGuid(); try { DataContext.CandidateSkills.InsertOnSubmit(objt); DataContext.SubmitChanges(); } catch (Exception e) { Console.WriteLine(e); DataContext.SubmitChanges(); } return(ResultModel.SuccessResult()); }
public async Task RemoveSkill(ulong primaryKey, ulong skillId) { Candidate candidate = null; try { candidate = _repository.GetAll().Where(candidate => candidate.Id == primaryKey).Include(candidate => candidate.CandidateSkill).ThenInclude(candidateSkill => candidateSkill.SkillNavigation).Single(); } finally { if (candidate == null) { throw new Exception($"A candidate with id \"{primaryKey}\" was not found."); } } CandidateSkill candidateSkill = candidate.CandidateSkill.SingleOrDefault(candidateSkill => candidateSkill.Skill == skillId); if (candidateSkill != null) { candidate.CandidateSkill.Remove(candidateSkill); candidate = await _repository.Update(candidate); } }
public async Task <string> UpdateProfileAsync(string candidateId, UpdateCandidateProfileViewModel model) { var candidate = this.candidatesRepository .All() .FirstOrDefault(c => c.Id == candidateId); if (candidate == null) { return(null); } candidate.FirstName = model.FirstName; candidate.LastName = model.LastName; candidate.PhoneNumber = model.PhoneNumber; candidate.ContactAddress = model.ContactAddress; candidate.Education = model.Education; candidate.AboutMe = model.SanitizedAboutMe; if (model.ProfilePicture != null) { if (candidate.ProfilePictureUrl != null) { CloudinaryService.DeleteFile(this.cloudinary, model.ApplicationUserId + PictureNameAddIn); } var pictureUrl = await CloudinaryService.UploadImageAsync(this.cloudinary, model.ProfilePicture, model.ApplicationUserId + PictureNameAddIn); if (pictureUrl == null) { return(null); } candidate.ProfilePictureUrl = pictureUrl; } candidate.ModifiedOn = DateTime.UtcNow; var candidateLanguagesIds = this.candidateLanguagesRepository .AllAsNoTracking() .Where(cl => cl.CandidateId == candidateId) .Select(cl => cl.LanguageId) .ToList(); // Add new ones foreach (var languageId in model.LanguagesIds) { if (!candidateLanguagesIds.Contains(languageId)) { var language = new CandidateLanguage { LanguageId = languageId, CandidateId = candidate.Id, CreatedOn = DateTime.UtcNow, }; await this.candidateLanguagesRepository.AddAsync(language); } } // Delete old ones foreach (var languageId in candidateLanguagesIds) { if (!model.LanguagesIds.Contains(languageId)) { var languages = this.candidateLanguagesRepository .All() .Where(cl => cl.LanguageId == languageId && cl.CandidateId == candidate.Id) .FirstOrDefault(); this.candidateLanguagesRepository.Delete(languages); } } var candidateSkillsIds = this.candidateSkillsRepository .AllAsNoTracking() .Where(cs => cs.CandidateId == candidateId) .Select(cs => cs.SkillId) .ToList(); // Add new ones foreach (var skillId in model.SkillsIds) { if (!candidateSkillsIds.Contains(skillId)) { var skill = new CandidateSkill { SkillId = skillId, CandidateId = candidate.Id, CreatedOn = DateTime.UtcNow, }; await this.candidateSkillsRepository.AddAsync(skill); } } // Delete old ones foreach (var skillId in candidateSkillsIds) { if (!model.SkillsIds.Contains(skillId)) { var skills = this.candidateSkillsRepository .All() .Where(cs => cs.SkillId == skillId && cs.CandidateId == candidate.Id) .FirstOrDefault(); this.candidateSkillsRepository.Delete(skills); } } try { this.candidatesRepository.Update(candidate); await this.candidatesRepository.SaveChangesAsync(); await this.candidateLanguagesRepository.SaveChangesAsync(); await this.candidateSkillsRepository.SaveChangesAsync(); return(candidate.Id); } catch (Exception) { return(null); } }
private void LoadModel(CandidateSkill source, CandidateSkill dest) { ShareFunctions.CopyPropertiesTo <CandidateSkill, CandidateSkill>(source, dest); dest.AspNetUser = DataContext.AspNetUsers.SingleOrDefault(x => x.Id.Equals(source.UserID)); }
public Skill(CandidateSkill obj) { ShareFunctions.CopyPropertiesTo <CandidateSkill, Skill>(obj, this); }
/// <summary> /// Adds a new skill. /// New candidates, new skills, are NOT added. Assume all references to /// refer to existing instances. /// </summary> /// <param name="order"></param> public void Add(CandidateSkill cs) { _candidateSkillRepository.Add(cs); }
public void Delete(CandidateSkill cs) { _candidateSkillRepository.Delete(cs); }
public async Task <string> CreateProfileAsync(CreateCandidateProfileInputModel model) { var candidate = AutoMapperConfig.MapperInstance.Map <Candidate>(model); if (model.ProfilePicture != null) { var pictureUrl = await CloudinaryService.UploadImageAsync(this.cloudinary, model.ProfilePicture, model.ApplicationUserId + PictureNameAddIn); if (pictureUrl == null) { return(null); } candidate.ProfilePictureUrl = pictureUrl; } candidate.CreatedOn = DateTime.UtcNow; var candidateLanguages = new List <CandidateLanguage>(); foreach (var languageId in model.LanguagesIds) { var language = new CandidateLanguage { Candidate = candidate, LanguageId = languageId, CreatedOn = DateTime.UtcNow, }; candidateLanguages.Add(language); } var candidateSkills = new List <CandidateSkill>(); foreach (var skillId in model.SkillsIds) { var skill = new CandidateSkill { Candidate = candidate, SkillId = skillId, CreatedOn = DateTime.UtcNow, }; candidateSkills.Add(skill); } try { await this.candidatesRepository.AddAsync(candidate); await this.candidateLanguagesRepository.AddRangeAsync(candidateLanguages); await this.candidateSkillsRepository.AddRangeAsync(candidateSkills); await this.candidatesRepository.SaveChangesAsync(); await this.candidateLanguagesRepository.SaveChangesAsync(); await this.candidateSkillsRepository.SaveChangesAsync(); return(candidate.Id); } catch (Exception) { return(null); } }