Пример #1
0
        public async Task <IActionResult> AddUnit(Unit unit, ICollection <int> systemIds)
        {
            unit.Systems = new List <UnitSystem>();
            foreach (var systemId in systemIds.OrderBy(v => v).ToList())
            {
                unit.Systems.Add(new UnitSystem()
                {
                    SystemId = systemId
                });
            }
            unit = _organizationService.AddUnit(unit);

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

            return(RedirectToAction(nameof(Units), new { id = unit.UnitId }));
        }