public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Task = await _context.Task.FindAsync(id); if (Task != null) { // The employee that completes a task should have his Current Workload updated Employee = await _employeeRepository.GetEmployeeByIdAsync(Task.EmployeeId.Value); Employee.CurrentWorkload -= Task.ExpectedTime; // Put end date to current time for task Task.EndDate = DateTime.Now.ToString("dd-MMMM-yy HH:mm"); // Change status to "Completed" Task.StatusId = 1; // Remove employee //Task.Employee = null; //not working await _context.SaveChangesAsync(); } return(RedirectToPage("../Programmer/menuProgrammer/")); }
// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(Skill).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SkillExists(Skill.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("Create")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Task = await _context.Task.FindAsync(id); if (Task != null) { // The employee that rejects a task should have his Current Workload updated Employee = await _employeeRepository.GetEmployeeByIdAsync(Task.EmployeeId.Value); Employee.CurrentWorkload -= Task.ExpectedTime; // Get the candidate programmers suitable for the task and the best candidate for it CandidateProgrammers = await _employeeRepository.GetProgrammersMinWorkload(Employee.Id); var bestCandidate = CandidateProgrammers.Cast <Data.Employee>().First(); // Update data for assigned programmer Task.EmployeeId = bestCandidate.Id; bestCandidate.CurrentWorkload += Task.ExpectedTime; await _context.SaveChangesAsync(); } return(RedirectToPage("../Programmer/menuProgrammer/")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Skill = await _context.Skill.FindAsync(id); if (Skill != null) { _context.Skill.Remove(Skill); await _context.SaveChangesAsync(); } return(RedirectToPage("Create")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Employee = await _context.Employee.FindAsync(id); if (Employee != null) { _context.Employee.Remove(Employee); await _context.SaveChangesAsync(); } return(RedirectToPage("../Manager/menuManager")); }
// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } try { _context.Skill.Add(Skill); await _context.SaveChangesAsync(); } catch { return(RedirectToPage("Create")); } return(RedirectToPage("Create")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Task = await _context.Task.FindAsync(id); if (Task != null) { // If task is "In Progress", update Current Workload if (Task.StatusId == 3) { Employee = await _employeeRepository.GetEmployeeByIdAsync(Task.EmployeeId.Value); Employee.CurrentWorkload -= Task.ExpectedTime; } _context.Task.Remove(Task); await _context.SaveChangesAsync(); } return(RedirectToPage("../Manager/menuManager")); }