コード例 #1
0
 public async Task <IdReply> AddAuthorizationNamespace(AuthorizationNamespaceDto authorizationNamespaceDto)
 {
     using (var authContext = GetContext())
     {
         var ns = new AuthorizationNamespace
         {
             Description = authorizationNamespaceDto.Description,
             Key         = authorizationNamespaceDto.Key
         };
         authContext.AuthorizationNamespaces.Add(ns);
         authContext.SaveChanges();
         return(IdReply.Success(ns.Id));
     }
 }
コード例 #2
0
        public async Task <ReplyBase> UpdateAuthorizationNamespace(AuthorizationNamespaceDto authorizationNamespaceDto)
        {
            using (var authContext = GetContext())
            {
                var existingNamespace = authContext.AuthorizationNamespaces.Find(authorizationNamespaceDto.Id);

                if (existingNamespace == null)
                {
                    return(ReplyBase.NotFound($"Unable to find authorization namespace with id {authorizationNamespaceDto.Id}"));
                }

                authContext.SaveChanges();
                return(ReplyBase.Success());
            }
        }