Пример #1
0
        public async Task <IActionResult> AddUserToSession([FromBody, Required] SessionDto sessionDto)
        {
            try
            {
                if (sessionDto == null)
                {
                    return(BadRequest());
                }

                foreach (var user in sessionDto.Users)
                {
                    await _service.AddUserToSession(sessionDto.Id, user.Id);
                }

                return(CreatedAtRoute("default", true));
            }
            catch (Exception ex)
            {
                Log.Error(ex, ex.Message);
                return(BadRequest(ex.Message));
            }
        }
Пример #2
0
        [InlineData(1)] //Session Id
        public async void CreateUser(int sessionId)
        {
            var newUser = new UserDto()
            {
                FirstName  = "Lionel",
                LastName   = "Messi",
                FullName   = "Lionel Messi",
                RoleId     = 2,
                Height     = 170,
                isEnabled  = true,
                isActive   = true,
                TeamId     = 1,
                Email      = "*****@*****.**",
                StartDate  = DateTime.UtcNow,
                EndDate    = DateTime.UtcNow.AddYears(1),
                PlayerInfo = new PlayerDto
                {
                    IsInjured       = false,
                    IsKeeper        = "No",
                    Availability    = "2017",
                    DominantSkillId = 1,
                    IsResting       = true,
                    JerseyNumber    = 10,
                    PositionId      = 6,
                    SubPositionId   = 2
                }
            };

            var userId = await _service.CreateUser(newUser);

            Assert.NotEqual(0, userId);

            //Create the session service
            var sessionSvc = new SessionService(this._fixture.Context);
            await sessionSvc.AddUserToSession(sessionId, userId);
        }