예제 #1
0
        private int IsExistChat(ChatDTO chatDTO)
        {
            var chat = repositories.ChatRepos.Get().Where(ch => ch.UniqueName == chatDTO.UniqueName).FirstOrDefault();

            if (chat == null)
            {
                return(-1);
            }
            else
            {
                return(chat.Id);
            }
        }
예제 #2
0
        public ChatDTO CreateNewChat(ChatDTO newChatDTO)
        {
            var id = IsExistChat(newChatDTO);

            if (id == -1)
            {
                repositories.ChatRepos.Insert(mapper.Map <Chat>(newChatDTO));
                repositories.Save();
                return(mapper.Map <ChatDTO>(repositories.ChatRepos.Get().LastOrDefault()));
            }
            else
            {
                return(null);
            }
        }
예제 #3
0
파일: BLLClass.cs 프로젝트: zm21/Zaolis
        public IEnumerable <MessageDTO> GetMessagesByChat(ChatDTO chat)
        {
            var res_chat = unit.ChatRepository.Get(c => c.Id == chat.Id, includeProperties: nameof(Chat.Messages))?.FirstOrDefault();

            return(_mapper.Map <IEnumerable <Message>, IEnumerable <MessageDTO> >(res_chat.Messages));
        }
예제 #4
0
파일: BLLClass.cs 프로젝트: zm21/Zaolis
 public IEnumerable <UserDTO> GetUsersByChat(ChatDTO chat)
 {
     return(_mapper.Map <IEnumerable <User>, IEnumerable <UserDTO> >((unit.ChatRepository.GetById(chat.Id).Users)));
 }