Beispiel #1
0
        public void TestJoin()
        {
            bool   NoReasonThisShouldBeTrue = true;
            bool   JoinCompleted            = false;
            bool   TestThrewException       = false;
            string eventName = "";

            try
            {
                NoReasonThisShouldBeTrue = ecp.ContainsEntry(testEvent.EventID, testCharacter.Name);
                ecp.JoinEvent(testEvent.EventID, testCharacter.Name, "AFK", new DateTime(2020, 12, 24));
                JoinCompleted = ecp.ContainsEntry(testEvent.EventID, testCharacter.Name);
                List <Event> events = (List <Event>)ep.GetGuildEventsByCharacterName(testEvent.GuildID, testCharacter.Name);
                eventName = (events[0]).Name;
            }catch (Exception)
            {
                TestThrewException = true;
            }finally
            {
                //Cleanup
            }

            Assert.AreEqual("Test Raid", eventName);
            Assert.IsFalse(NoReasonThisShouldBeTrue);
            Assert.IsTrue(JoinCompleted);
            Assert.IsFalse(TestThrewException);
        }
Beispiel #2
0
        public ActionResult <string> DeleteEventCharacter([FromHeader(Name = "x-eventid")] int eventID, [FromHeader(Name = "x-charactername")] string characterName)
        {
            // Check if EventCharacter contains entry with given eventID and characterName,
            // if so: delete EventCharacter from EventCharacter
            // if not: delete EventCharacter from EventCharacterWaitingList instead

            IAuthService authService = new JWTService(clientSettings.Value.SecretKey);
            string       token       = HttpContext.Request.Headers["Authorization"];

            try
            {
                if (!authService.IsTokenValid(token))
                {
                    return(BadRequest("Unauthorized Access"));
                }
                else
                {
                    if (eventCharacterProcessor.ContainsEntry(eventID, characterName))
                    {
                        if (eventCharacterProcessor.DeleteEventCharacterByEventIDAndCharacterName(eventID, characterName))
                        {
                            return("Succesfully deleted from participants list");
                        }
                        else
                        {
                            return("Not succesfully deleted");
                        }
                    }
                    else
                    {
                        if (eventCharacterWaitingListProcessor.DeleteEventCharacterByEventIDAndCharacterName(eventID, characterName))
                        {
                            return("Succesfully deleted from waiting list");
                        }
                        else
                        {
                            return("Not succesfully deleted from waiting list");
                        }
                    }
                }
            } catch
            {
                return(BadRequest("Unauthorized Access"));
            }
        }