public async Task <IActionResult> UpdateStatus(int?id, int?status) { if (id == null || status == null || !Enum.IsDefined(typeof(ApplicationStatus), status.Value)) { return(BadRequest()); } JobApplication app = await _context.JobApplications.Include(x => x.JobOffer).FirstOrDefaultAsync(app => app.Id == id); if (app == null) { return(NotFound()); } if (app.JobOffer.CreatorId != User.GetId()) { return(Forbid()); } app.Status = (ApplicationStatus)status.Value; _context.Update(app); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(DetailsHR), "JobOffers", new { id = app.JobOfferId })); }
public async Task <ActionResult> Edit(JobOffer model) { if (!ModelState.IsValid) { return(View(model)); } JobOffer offer = await _context.JobOffers.FirstOrDefaultAsync(o => o.Id == model.Id); if (offer == null) { return(BadRequest()); } if (User.GetId() != offer.CreatorId) { return(Forbid()); } offer.JobTitle = model.JobTitle; offer.Description = model.Description; offer.CompanyId = model.CompanyId; offer.Location = model.Location; offer.SalaryFrom = model.SalaryFrom; offer.SalaryTo = model.SalaryTo; offer.ValidUntil = model.ValidUntil; _context.Update(offer); await _context.SaveChangesAsync(); return(RedirectToAction("DetailsHR", new { id = model.Id })); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Company company) { if (company == null || id != company.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(company); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CompanyExists(company.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(company)); }
public async Task <IActionResult> UpdateRole(int?id, int?roleId) { if (id == null || roleId == null) { return(BadRequest()); } var user = await _context.Users.Where(x => x.RoleId != 3).FirstOrDefaultAsync(u => u.Id == id); if (user == null) { return(NotFound()); } user.RoleId = roleId.Value; _context.Update(user); await _context.SaveChangesAsync(); return(Ok()); }