コード例 #1
0
        public async Task Add(ApiResourceInput value)
        {
            var resource = mapper.Map <Scope>(value);

            configDb.Scopes.Add(resource);
            await configDb.SaveChangesAsync();
        }
コード例 #2
0
        public async Task Update(int id, ApiResourceInput value)
        {
            var resource = await SelectFullEntity().Where(i => i.Id == id).FirstOrDefaultAsync();

            if (resource == null)
            {
                throw new InvalidOperationException($"Cannot find resource with id '{id}'.");
            }

            mapper.Map <ApiResourceInput, Scope>(value, resource);
            configDb.Scopes.Update(resource);
            await configDb.SaveChangesAsync();
        }
コード例 #3
0
        public async Task AddOrUpdate(ApiResourceInput value)
        {
            var existing = await SelectFullEntity().Where(i => i.Name == value.ScopeName).FirstOrDefaultAsync();

            if (existing == null)
            {
                await Add(value);
            }
            else
            {
                mapper.Map <ApiResourceInput, Scope>(value, existing);
                configDb.Scopes.Update(existing);
                await configDb.SaveChangesAsync();
            }
        }
コード例 #4
0
 public Task Put(int id, [FromBody] ApiResourceInput value)
 {
     return(apiResourceRepository.Update(id, value));
 }
コード例 #5
0
 public Task Post([FromBody] ApiResourceInput value)
 {
     return(apiResourceRepository.Add(value));
 }