Пример #1
0
        public async Task <IActionResult> OnPostAsync(int?id, string technicianID)
        {
            if (id == null || technicianID == null)
            {
                return(NotFound());
            }

            Projects = await _context.Project
                       .Include(d => d.Client).ToListAsync();

            Projects = Projects.Where(s => s.ID.Equals(id)).ToList();;

            Project = Projects[0];

            TechnicianSelected = await _context.Technician.FindAsync(technicianID);

            if (Project != null && TechnicianSelected != null)
            {
                ProjectAssigned NewProject = new ProjectAssigned();
                NewProject.Specialty   = Project.Specialty;
                NewProject.Level       = Project.Level;
                NewProject.Description = Project.Description;
                NewProject.NHours      = Project.NHours;
                NewProject.Technician  = TechnicianSelected;
                NewProject.Client      = Project.Client;

                _context.ProjectAssigned.Add(NewProject);
                _context.Project.Remove(Project);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Пример #2
0
        public async Task <IActionResult> OnPostAsync(int?id, Boolean Positive, String Comment)
        {
            if (id == null)
            {
                return(NotFound());
            }
            Feedback Feedback = new Feedback();

            Feedback.Positive = Positive;
            Feedback.Comment  = Comment;

            Projects = await _context.ProjectAssigned
                       .Include(e => e.Technician)
                       .Include(d => d.Client).ToListAsync();

            Projects = Projects.Where(s => s.ID.Equals(id)).ToList();;

            Project = Projects[0];

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            if (Project != null)
            {
                _context.Feedback.Add(Feedback);

                ProjectFinished NewProject = new ProjectFinished();
                NewProject.ID          = Project.ID;
                NewProject.Specialty   = Project.Specialty;
                NewProject.Level       = Project.Level;
                NewProject.Description = Project.Description;
                NewProject.NHours      = Project.NHours;
                NewProject.Technician  = Project.Technician;
                NewProject.Client      = Project.Client;
                NewProject.Feedback    = Feedback;

                _context.ProjectAssigned.Remove(Project);
                _context.ProjectFinished.Add(NewProject);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }