Beispiel #1
0
        public async Task <long> AddRoleAsync(Role role)
        {
            ValidateNotNull(role);
            await ValidateUniqueId(_roleDao, role.Id);

            var roleExist = await _roleDao.ExistAsync(role.Label);

            if (roleExist.Exist)
            {
                var duplicateEntryException = new DuplicateEntryException(roleExist.Id, "Role label already exist!");
                Logger.Error(duplicateEntryException, "{Role} label already exists", role);
                throw duplicateEntryException;
            }

            return((await _roleDao.FluentInsert(role).ExecuteAsync()).FirstOrDefault());
        }