public async Task <IActionResult> Create([Bind("Id,Name,Location,IndustryId,UserId,TopJobId")] JobEmployer jobEmployer) { if (ModelState.IsValid) { _repo.Add(jobEmployer); await _repo.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["IndustryId"] = new SelectList(_repo.Industries, "Id", "Id", jobEmployer.IndustryId); ViewData["TopJobId"] = new SelectList(_repo.TopJobs, "Id", "Id", jobEmployer.TopJobId); return(View(jobEmployer)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Location,IndustryId,UserId,TopJobId")] JobEmployer jobEmployer) { if (id != jobEmployer.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _repo.Update(jobEmployer); await _repo.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { throw; } return(RedirectToAction(nameof(Index))); } ViewData["IndustryId"] = new SelectList(_repo.Industries, "Id", "Id", jobEmployer.IndustryId); ViewData["TopJobId"] = new SelectList(_repo.TopJobs, "Id", "Id", jobEmployer.TopJobId); return(View(jobEmployer)); }
public async Task Update(JobEmployer jobEmployer) { _myJob.JobEmployers.Update(jobEmployer); await _myJob.SaveChangesAsync(); }
public async Task Add(JobEmployer jobEmployer) { await _myJob.JobEmployers.AddAsync(jobEmployer); await _myJob.SaveChangesAsync(); }