public async Task <IActionResult> Edit(int id, [Bind("ID,Job,Name,Services")] Worker worker) { if (id != worker.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(worker); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!WorkerExists(worker.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(worker)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Email,Phone,Gender,Specialization,Created")] Worker worker) { if (id != worker.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(worker); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!WorkerExists(worker.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(worker)); }
public async Task <IActionResult> Edit(int id, [Bind("supervisiorID,first_name,last_name,department")] Supervisior supervisior) { if (id != supervisior.supervisiorID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(supervisior); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SupervisiorExists(supervisior.supervisiorID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(supervisior)); }
public async Task <IActionResult> Edit(int id, [Bind("workerID,first_name,last_name,hired_date,SupervisiorFK")] Worker worker) { if (id != worker.workerID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(worker); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!WorkerExists(worker.workerID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["SupervisiorFK"] = new SelectList(_context.Supervisiors, "supervisiorID", "supervisiorID", worker.SupervisiorFK); return(View(worker)); }
public async Task <IActionResult> Edit(int id, [Bind("SalaryID,WorkerID,PositionID,Bonus")] Salary salary) { if (id != salary.SalaryID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(salary); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SalaryExists(salary.SalaryID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["PositionID"] = new SelectList(_context.Positions, "PositionID", "PositionID", salary.PositionID); ViewData["WorkerID"] = new SelectList(_context.Workers, "ID", "ID", salary.WorkerID); return(View(salary)); }
public async Task <IActionResult> Edit(int id, [Bind("PositionID,Name,Amount")] Position position) { if (id != position.PositionID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(position); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PositionExists(position.PositionID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(position)); }
public async Task <IActionResult> Edit(int id, [Bind("WorkerCommentID,Name,Comment,StarRating,LastUpdated,WorkerID")] WorkerComment workerComment) { if (id != workerComment.WorkerCommentID) { return(NotFound()); } if (ModelState.IsValid) { // Must be Admin, or original commenter IdentityUser user = await _userManager.GetUserAsync(HttpContext.User); if (!User.IsInRole("Admin") && (!user.UserName.ToUpper().Equals(workerComment.Name.ToUpper()))) { return(Forbid()); } try { workerComment.LastUpdated = DateTime.Now; _context.Update(workerComment); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!WorkerCommentExists(workerComment.WorkerCommentID)) { return(NotFound()); } else { throw; } } if (User.IsInRole("Admin")) { return(RedirectToAction(nameof(Index))); } // user is in a Customer role return(RedirectToAction("ShowComments", new { id = workerComment.WorkerID })); } return(View(workerComment)); }