Ejemplo n.º 1
0
        public async Task <IActionResult> AddSupportUnit(SupportUnit unit, List <int> employeeIds, List <int> systemIds)
        {
            unit = _organizationService.AddSupportUnit(unit);

            var employees = _userService.GetEmployees(employeeIds);

            foreach (var employee in employees)
            {
                employee.SupportUnitId = unit.SupportUnitId;
            }
            _userService.SaveChanges();

            var systems = _systemService.GetSystems(systemIds);

            foreach (var system in systems)
            {
                system.SupportUnitId = unit.SupportUnitId;
            }
            _systemService.SaveChanges();

            var identity = (ClaimsIdentity)User.Identity;
            await _auditLog.Append(identity.GetClaimAsInt("EmployeeId"), LogActionType.Create, LogResourceType.SupportUnit, unit.SupportUnitId,
                                   $"{identity.GetClaim(ClaimTypes.Name)} created support unit with id {unit.SupportUnitId}");

            return(RedirectToAction(nameof(ViewSupportUnit), new { id = unit.SupportUnitId }));
        }