コード例 #1
0
        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/"));
        }
コード例 #2
0
        // 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"));
        }
コード例 #3
0
        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/"));
        }
コード例 #4
0
        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"));
        }
コード例 #5
0
        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"));
        }
コード例 #6
0
        // 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"));
        }
コード例 #7
0
        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"));
        }