Пример #1
0
        public async Task <IActionResult> LeaveSession([FromBody] SessionMembershipViewModel joinSessionViewModel)
        {
            try
            {
                var user = await _usersRepository.FindUser(joinSessionViewModel.UserId);

                var session = await _sessionsRepository.GetSession(joinSessionViewModel.SessionId);

                if (user != null && session != null)
                {
                    await _sessionsRepository.RemoveUserFromSession(user, session);

                    return(Ok(session));
                }
                else
                {
                    return(BadRequest(new ErrorMessage("Unable to leave session")));
                }
            }
            catch (Exception ex)
            {
                return(HandleError(ex));
            }
        }