Beispiel #1
0
        public async Task LeaveUserToLobi(LobiInputDto input)
        {
            var lobiUser = await _context.LobiUsers.FirstOrDefaultAsync(x => x.LobiId == input.LobiId && x.UserId == input.UserId);

            if (lobiUser != null)
            {
                _context.Entry <LobiUser>(lobiUser).State = EntityState.Deleted;
                _context.SaveChanges();
            }
        }
Beispiel #2
0
        public async Task JoinUserToLobi(LobiInputDto input)
        {
            var lobi = await _lobiRepository.GetQueryable().Include(x => x.LobiUsers).FirstOrDefaultAsync(x => x.Id == input.LobiId);

            if (!lobi.LobiUsers.Any(x => x.UserId == input.UserId))
            {
                lobi.LobiUsers.Add(new LobiUser()
                {
                    UserId = input.UserId
                });
                await _lobiRepository.UpdateAsync(lobi);
            }
        }