public ActionResult Post([FromBody] Roles newRole)
        {
            DotNetEnv.Env.Load();
            postgreUnitOfWork db = new postgreUnitOfWork(System.Environment.GetEnvironmentVariable("CONN_STR"));

            db.RoleRepo.Create(newRole);
            db.Commit();

            return(Ok());
        }
Beispiel #2
0
        public void CreateRoomTest()
        {
            using (var uw = new postgreUnitOfWork(connection))
            {
                Room newRoom = new Room(6);
                uw.RoomRepo.Create(newRoom);
                uw.Commit();

                Room foundRoom = uw.RoomRepo.FindRoom(newRoom.ID);
                Assert.True(foundRoom != null);
            }
        }
        public DBRole Put([FromBody] UpdateRole updateRole)
        {
            DotNetEnv.Env.Load();
            postgreUnitOfWork db = new postgreUnitOfWork(System.Environment.GetEnvironmentVariable("CONN_STR"));

            DBRole newRole = new DBRole(updateRole.id, updateRole.name, DateTime.Now, DateTime.Now);

            DBRole updated = db.RoleRepo.UpdateRole(newRole);

            db.Commit();

            return(updated);
        }
        public ActionResult <User> Post([FromBody] NewUser newUser)
        {
            User u = Player.createUser(newUser.name);

            DotNetEnv.Env.Load();
            postgreUnitOfWork db = new postgreUnitOfWork(System.Environment.GetEnvironmentVariable("CONN_STR"));

            db.UserRepo.Create(u);
            db.Commit();

            User current = db.UserRepo.FindById(u.ID);

            return(u);
        }
        public ActionResult Delete([FromQuery] int id)
        {
            DotNetEnv.Env.Load();
            postgreUnitOfWork db = new postgreUnitOfWork(System.Environment.GetEnvironmentVariable("CONN_STR"));

            if (db.RoleRepo.DeleteRole(id) == null)
            {
                return(NotFound());
            }
            else
            {
                db.Commit();
                return(Ok());
            }
        }