public Authority Create(string authorityKey, string displayName) { if (string.IsNullOrEmpty(authorityKey)) { throw new ArgumentNullException(nameof(authorityKey)); } var authority = _authorityRepository.GetByKey(authorityKey).SingleOrDefault(); if (authority != null) { throw new AuthorityAlreadyExistsException(); } authority = new Authorities { DisplayName = displayName, Key = authorityKey }; _authorityRepository.Insert(authority); _authorityRepository.Save(); return(authority.ToModel()); }
/// <summary> /// 保存 /// </summary> public override void Save() { authorityRepository.Save(this); }