public IActionResult Delete(string name) { var currentUser = HttpContext.User.Identity.Name; if (!_securityRepository.UserIsAdmin(HttpContext)) { return(_securityRepository.Gate(GateType.Unathorised, AccessLogAction.GroupDelete, currentUser, _object, name)); } var entity = _groupRepository.GetByName(name); if (String.IsNullOrWhiteSpace(entity.Name)) { return(_securityRepository.Gate(GateType.NotFound, AccessLogAction.GroupDelete, currentUser, _object, name)); } _groupRepository.DeleteById(entity.Id); _securityRepository.LogUserAction(currentUser, AccessLogAction.GroupDelete, name, _object, true); _groupRepository.SaveChanges(); return(Ok()); }