public async Task <IActionResult> PutCandidateExperience(int id, CandidateExperience candidateExperience) { if (id != candidateExperience.Id) { return(BadRequest()); } _context.Entry(candidateExperience).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CandidateExperienceExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult AddCandidateExperience(CandidateExperience ce) { ViewBag.UserId = new SelectList(db.AspNetUsers, "Id", "Email", ce.UserId); string id = User.Identity.GetUserId(); ce.UserId = id; if (ModelState.IsValid) { if (ce.Id > 0) { db.Entry(ce).State = EntityState.Modified; db.SaveChanges(); Candidate candidate = db.Candidates.Find(id); candidate.YearsExperience = GetCandidateExperience(); db.Entry(candidate).State = EntityState.Modified; db.SaveChanges(); } else { db.CandidateExperiences.Add(ce); db.SaveChanges(); Candidate candidate = db.Candidates.Find(id); candidate.YearsExperience = GetCandidateExperience(); db.Entry(candidate).State = EntityState.Modified; db.SaveChanges(); } } return(View(ce)); }
public async Task <ActionResult> DeleteConfirmed(int id) { CandidateExperience candidateExperience = await db.CandidateExperience.FindAsync(id); db.CandidateExperience.Remove(candidateExperience); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public IActionResult PostCandidateExperience([FromBody] CandidateExperience candidateExperience) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } candidateExperience.Id = _candidateExperienceRepository.AddCandidateExperience(candidateExperience); return(CreatedAtAction("PostCandidateExperience", new { id = candidateExperience.Id }, candidateExperience)); }
public async Task <ActionResult> Edit([Bind(Include = "IdExp,Id_CV,Description,DateStart,DateEnd")] CandidateExperience candidateExperience) { if (ModelState.IsValid) { db.Entry(candidateExperience).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.Id_CV = new SelectList(db.Candidates, "IdCV", "User", candidateExperience.Id_CV); return(View(candidateExperience)); }
public IActionResult PutCandidateExperience([FromBody] CandidateExperience candidateExperience) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _candidateExperienceRepository.EditCandidateExperience(candidateExperience); return(Ok(candidateExperience)); }
// GET: CandidateExperiences/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CandidateExperience candidateExperience = await db.CandidateExperience.FindAsync(id); if (candidateExperience == null) { return(HttpNotFound()); } return(View(candidateExperience)); }
// GET: CandidateExperiences/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CandidateExperience candidateExperience = await db.CandidateExperience.FindAsync(id); if (candidateExperience == null) { return(HttpNotFound()); } ViewBag.Id_CV = new SelectList(db.Candidates, "IdCV", "User", candidateExperience.Id_CV); return(View(candidateExperience)); }
public async Task <CandidateExperience> PostCandidateExperience(CandidateExperience candidateExperience) { _oCandidateExperience = new CandidateExperience(); using (var httpClient = new HttpClient(_clientHandler)) { StringContent content = new StringContent(JsonConvert.SerializeObject(candidateExperience), Encoding.UTF8, "application/json"); using (var response = await httpClient.PostAsync("https://localhost:44304/api/CandidateExperiences", content)) { string apiResponse = await response.Content.ReadAsStringAsync(); _oCandidateExperience = JsonConvert.DeserializeObject <CandidateExperience>(apiResponse); } } return(_oCandidateExperience); }
//Edit experience public JsonResult EditExperience(int?Id_candidate, int id_experience, string companyname, string from_date, string to_date, string description, string position) { CandidateExperience experienceToUpdate = db.CandidateExperiences.Single(x => x.Id_candidate == Id_candidate && x.Id_experience == id_experience); bool result = false; experienceToUpdate.company_name = companyname; experienceToUpdate.from_date = from_date; experienceToUpdate.to_date = to_date; experienceToUpdate.description = description; experienceToUpdate.position = position; db.SaveChanges(); result = true; return(Json(result, JsonRequestBehavior.AllowGet)); }
//remove experience row public JsonResult DeleteExperience(int?Id_candidate, int?Id_experience) { NoBordersDB db = new NoBordersDB(); CandidateProfile candidateProfile = db.CandidateProfiles.Find(Id_candidate); CandidateExperience candidateExperience = db.CandidateExperiences.SingleOrDefault(x => x.Id_candidate == Id_candidate && x.Id_experience == Id_experience); bool result = false; if (candidateExperience != null) { db.CandidateExperiences.Remove(candidateExperience); db.SaveChanges(); result = true; } return(Json(result, JsonRequestBehavior.AllowGet)); }
//add Experience public JsonResult AddExperience(int?Id_candidate, string companyname, string from_date, string to_date, string description, string position) { CandidateExperience candidateExperience = new CandidateExperience(); bool result = false; candidateExperience.Id_candidate = (int)Id_candidate; candidateExperience.company_name = companyname; candidateExperience.from_date = from_date; candidateExperience.to_date = to_date; candidateExperience.description = description; candidateExperience.position = position; db.CandidateExperiences.Add(candidateExperience); db.SaveChanges(); result = true; return(Json(result, JsonRequestBehavior.AllowGet)); }
public async Task <IActionResult> PutCandidateExperience(int Id, CandidateExperience candidateExperience) { _oCandidateExperience = new CandidateExperience(); using (var httpClient = new HttpClient(_clientHandler)) { StringContent content = new StringContent(JsonConvert.SerializeObject(candidateExperience), Encoding.UTF8, "application/json"); using (var response = await httpClient.PutAsync("https://localhost:44304/api/CandidateExperiences/" + Id, content)) { string apiResponse = await response.Content.ReadAsStringAsync(); if (response.IsSuccessStatusCode) { _oCandidateExperience = JsonConvert.DeserializeObject <CandidateExperience>(apiResponse); return(Ok(_oCandidateExperience)); } else { return(BadRequest()); } } } }
public async Task <ActionResult <CandidateExperience> > PostCandidateExperience(CandidateExperience candidateExperience) { candidateExperience.Experience = await _context.Experience.FindAsync(candidateExperience.ExperienceId); candidateExperience.Domain = await _context.Domain.FindAsync(candidateExperience.DomainId); candidateExperience.Candidate = await _context.Candidate.FindAsync(candidateExperience.CandidateId); candidateExperience.Candidate.User = await _context.User.FindAsync(candidateExperience.Candidate.UserId); candidateExperience.Candidate.Country = await _context.Country.FindAsync(candidateExperience.Candidate.CountryId); candidateExperience.Candidate.SalaryWish = await _context.SalaryWish.FindAsync(candidateExperience.Candidate.SalaryWishId); candidateExperience.Candidate.DrivingLicence = await _context.DrivingLicence.FindAsync(candidateExperience.Candidate.DrivingLicenceId); _context.CandidateExperience.Add(candidateExperience); await _context.SaveChangesAsync(); return(CreatedAtAction("GetCandidateExperience", new { id = candidateExperience.Id }, candidateExperience)); }