コード例 #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));
        }
コード例 #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"));
        }