public IHttpActionResult PostDatabaseDB(DatabaseModel database) { // Vérification de l'appelant IHttpActionResult result = this.SecurityCheckRoleAdminOrOwner(database.UserLogin); if (result != null) { return(result); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } DatabaseDB databaseDB = service.AddDatabase(database); if (databaseDB == null) { return(Conflict()); } FillPermissions(databaseDB, this.GetJWTIdentity()); return(CreatedAtRoute("DefaultApi", new { id = databaseDB.Id }, databaseDB)); }
public async Task Connect() { string dbid = $"dc-{Context.Guild.Id}"; if (dsv.Exists(dbid)) { await Context.Message.AddReactionAsync(new Emoji("✅")); } else { dsv.AddDatabase(dbid); await Context.Message.AddReactionAsync(new Emoji("📡")); } }
public void TestAddDatabase() { DatabaseModel database = new DatabaseModel { ServerId = UnitTestDatabase.serverId, NomBD = "DBUbunitTest", UserLogin = "******", Commentaire = "Depuis les Tests Unitaires" }; DatabaseDB databaseDB = service.AddDatabase(database); Assert.IsNotNull(databaseDB); Assert.IsTrue(databaseDB.Id > 0); Assert.IsNotNull(databaseDB.DateCreation); Assert.IsTrue(databaseDB.DatabaseGroupUsers.Count == 1); }
public ActionResult <DatabaseDb> PostDatabaseDb(DatabaseModel database) { // Vérification de l'appelant if (!this.SecurityCheckRoleAdminOrOwner(database.UserLogin)) { return(Forbid()); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } DatabaseDb databaseDb = _service.AddDatabase(database); if (databaseDb == null) { return(Conflict()); } FillPermissions(databaseDb); return(CreatedAtAction(nameof(GetDatabase), new { id = databaseDb.Id }, databaseDb)); }