Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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"));
        }
Exemplo n.º 3
0
        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 }));
        }
Exemplo n.º 4
0
 public IActionResult AddEmployeeToIncident(int id)
 {
     IncidentEmployeeProcessor.AddEmployeeToIncident(id, HttpContext.GetCurrentEmployeeModel().Id);
     return(RedirectToAction("DetailsIncident", new { id }));
 }