public async Task Add(ApiResourceInput value) { var resource = mapper.Map <Scope>(value); configDb.Scopes.Add(resource); await configDb.SaveChangesAsync(); }
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(); }
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(); } }
public Task Put(int id, [FromBody] ApiResourceInput value) { return(apiResourceRepository.Update(id, value)); }
public Task Post([FromBody] ApiResourceInput value) { return(apiResourceRepository.Add(value)); }