public IActionResult DetailsIncident(int id)
        {
            int count                          = 0;
            var incidentData                   = IncidentProcessor.LoadIncidentById(id);
            var incidentEmployeeData           = IncidentEmployeeProcessor.LoadEmployeesByIncidentId(id);
            var incidentStepData               = IncidentStepProcessor.LoadStepsByIncidentId(id);
            List <IncidentStepModel> steps     = new List <IncidentStepModel>();
            List <EmployeeModel>     employees = new List <EmployeeModel>();

            foreach (var step in incidentStepData)
            {
                count++;
                steps.Add(new IncidentStepModel
                {
                    title                 = step.title,
                    context               = step.context,
                    datetimeEnd           = step.datetimeEnd,
                    datetimeStart         = step.datetimeStart,
                    employee_id_createdby = step.employee_id_createdby,
                    employee_id_endedby   = step.employee_id_endedby,
                    id          = step.id,
                    incident_id = step.incident_id,
                    status      = step.status,
                    stepnumber  = count
                }
                          );
            }

            foreach (var employee in incidentEmployeeData)
            {
                var data = EmployeeProcessor.GetUserById(employee.Employee_Id);
                employees.Add(new EmployeeModel
                {
                    Firstname          = data.Firstname,
                    Lastname           = data.Lastname,
                    ProfilePicturePath = data.ProfilePicturePath,
                    Id = data.ID
                }
                              );
            }
            IncidentDetailsViewModel incidentDetails = new IncidentDetailsViewModel
            {
                id            = id,
                Context       = incidentData.Context,
                Customer      = incidentData.Customer,
                CustomerEmail = incidentData.CustomerEmail,
                Title         = incidentData.Title,
                Status        = incidentData.Status,
                steps         = steps,
                employees     = employees
            };

            ViewData["webroot"] = _env.WebRootPath;
            return(View(incidentDetails));
        }
Exemple #2
0
 public IActionResult CreateStep(IncidentStepModel data, int id)
 {
     if (ModelState.IsValid)
     {
         IncidentStepProcessor.CreateStep(
             HttpContext.GetCurrentEmployeeModel().Id,
             data.id,
             data.context,
             data.title
             );
         return(RedirectToAction("DetailsIncident", "Incident", new { id }));
     }
     return(View());
 }
        public IActionResult DeleteIncident(int id)
        {
            var steps             = IncidentStepProcessor.LoadStepsByIncidentId(id);
            var incidentEmployees = IncidentEmployeeProcessor.LoadEmployeesByIncidentId(id);

            foreach (var employee in incidentEmployees)
            {
                IncidentEmployeeProcessor.RemoveEmployeeFromIncident(id, employee.Employee_Id);
            }
            foreach (var step in steps)
            {
                IncidentStepProcessor.DeleteStep(step.id);
            }
            IncidentProcessor.DeleteIncident(id);
            return(RedirectToAction("ViewIncidents"));
        }
        public IActionResult RemoveEmployeeFromIncident(int id)
        {
            var stepData = IncidentStepProcessor.LoadStepsByIncidentId(id);

            foreach (var step in stepData)
            {
                var stepEmployeeData = IncidentStepEmployeeprocessor.LoadEmployeesFromStepId(step.id);
                foreach (var employee in stepEmployeeData)
                {
                    if (employee.id == HttpContext.GetCurrentEmployeeModel().Id)
                    {
                        IncidentStepEmployeeprocessor.RemoveEmployeeFromStep(step.id, HttpContext.GetCurrentEmployeeModel().Id);
                    }
                }
            }
            IncidentEmployeeProcessor.RemoveEmployeeFromIncident(id, HttpContext.GetCurrentEmployeeModel().Id);
            return(RedirectToAction("DetailsIncident", new { id = id }));
        }
Exemple #5
0
        public IActionResult DetailsStep(int id)
        {
            var stepData                   = IncidentStepProcessor.LoadStepById(id);
            var StepEmployeeData           = IncidentStepEmployeeprocessor.LoadEmployeesFromStepId(id);
            List <EmployeeModel> employees = new List <EmployeeModel>();

            foreach (var employee in StepEmployeeData)
            {
                var employeeData = EmployeeProcessor.GetUserById(employee.employee_id);
                employees.Add(new EmployeeModel
                {
                    Address            = employeeData.Address,
                    City               = employeeData.City,
                    Firstname          = employeeData.Firstname,
                    ProfilePicturePath = employeeData.ProfilePicturePath,
                    Profession         = employeeData.Profession,
                    Lastname           = employeeData.Lastname,
                    Email              = employeeData.Email,
                    Id    = employeeData.ID,
                    Phone = employeeData.Phone
                }
                              );
            }
            IncidentStepDetailsViewModel stepDetails = new IncidentStepDetailsViewModel
            {
                context               = stepData.context,
                title                 = stepData.title,
                datetimeStart         = stepData.datetimeStart,
                datetimeEnd           = stepData.datetimeEnd,
                employee              = employees,
                employee_id_createdby = stepData.employee_id_createdby,
                employee_id_endedby   = stepData.employee_id_endedby,
                id          = stepData.id,
                incident_id = stepData.incident_id,
                status      = stepData.status
            };

            return(View(stepDetails));
        }
Exemple #6
0
 public IActionResult CloseStep(int id)
 {
     IncidentStepProcessor.CloseStep(id, HttpContext.GetCurrentEmployeeModel().Id);
     return(RedirectToAction("DetailsStep", new { id }));
 }
Exemple #7
0
 public IActionResult DeleteStep(int id, int incident_Id)
 {
     IncidentStepProcessor.DeleteStep(id);
     return(RedirectToAction("DetailsIncident", "Incident", new { id = incident_Id }));
 }