public async Task <List <DomainPermission> > GetDomainPermissions(int userId) { using (MySqlConnection connection = new MySqlConnection(await _connectionInfo.GetConnectionStringAsync())) { await connection.OpenAsync().ConfigureAwait(false); MySqlCommand command = new MySqlCommand(UserDaoResources.SelectDomainPermissions, connection); command.Parameters.AddWithValue("userId", userId); command.Prepare(); DbDataReader reader = await command.ExecuteReaderAsync(); List <DomainPermission> domainPermissions = new List <DomainPermission>(); while (await reader.ReadAsync()) { DomainPermission domainPermission = new DomainPermission( new Api.Domain.Domain( reader.GetInt32("domain_id"), reader.GetString("domain_name")), new List <Permission> { Permission.ViewAggregateData }); domainPermissions.Add(domainPermission); } connection.Close(); return(domainPermissions); } }
public DomainPermission Put(DomainPermission request) { DomainPermissionEntity entity = request.TranslateToEntity(); entity = GenericRepository.Add(AuthAdminDatabase, DomainPermissionsCollection, entity); return entity.TranslateToResponse(); }
public DomainPermission Post(DomainPermission request) { DomainPermissionEntity entity = request.TranslateToEntity(); if (entity.Id == 0) entity.Id = GenericRepository.GetMaxIdIncrement<DomainPermissionEntity>(AuthAdminDatabase, DomainPermissionsCollection); entity = GenericRepository.Add(AuthAdminDatabase, DomainPermissionsCollection, entity); return entity.TranslateToResponse(); }
public DomainPermission Get(DomainPermission request) { if (request.Id != 0) { DomainPermissionEntity entity = GenericRepository.GetItemTopById<DomainPermissionEntity>(AuthAdminDatabase, DomainPermissionsCollection, request.Id); if (entity == null) return null; return entity.TranslateToResponse(); } return null; }
public DomainPermission Delete(DomainPermission request) { GenericRepository.DeleteById<DomainPermissionEntity>(AuthAdminDatabase, DomainPermissionsCollection, request.Id); return null; }
public void Init() { instance = new DomainPermission(); }