예제 #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);
        }
예제 #2
0
        public ActionResult <EventCharacter> Post([FromBody] EventCharacter ec, [FromHeader(Name = "x-rowid")] byte[] rowId)
        {
            IAuthService authService = new JWTService(clientSettings.Value.SecretKey);
            string       token       = HttpContext.Request.Headers["Authorization"];

            try
            {
                if (!authService.IsTokenValid(token))
                {
                    return(BadRequest("Unauthorized Access"));
                }
                else
                {
                    if (eventProcessor.HasEventChangedRowVersion(ec.EventID, rowId))
                    {
                        // TODO change response type
                        return(BadRequest("The information about event you tried to join has changed. Joining event was unsuccessful"));
                    }

                    if (eventCharacterProcessor.JoinEvent(ec.EventID, ec.CharacterName, ec.CharacterRole, ec.SignUpDateTime))
                    {
                        return(ec);
                    }
                    return(BadRequest("Invalid data."));
                }
            } catch
            {
                return(BadRequest("Unauthorized Access"));
            }
        }