public Model.ChatRoom CreateChatRoom(Guid creatorUserId, Guid invitedUserId, string chatName = "") { if (!_userService.IsUserValid(creatorUserId) && !_userService.IsUserValid(invitedUserId)) { throw new ValidationException("Invalid user Id's"); } //1. create room var chatRoom = new Model.ChatRoom() { Name = !string.IsNullOrEmpty(chatName) ? chatName : "roomName" }; _chatRoomRepository.Add(chatRoom); //2. create room users var chatRoomUsers = new List <Model.ChatRoomUser>() { new Model.ChatRoomUser() { ChatRoom = chatRoom, UserId = creatorUserId }, new Model.ChatRoomUser() { ChatRoom = chatRoom, UserId = invitedUserId } }; _chatRoomUserRepository.AddRange(chatRoomUsers); _unitOfWork.Commit(); return(chatRoom); }
public void Post(ChatRoomUser user) { repositry.Add(user); }