コード例 #1
0
        public async Task <bool> SaveChatRecord(GlobalChatDto chatDto)
        {
            // convert string to int
            var temp   = chatDto.Username;
            var userId = Convert.ToInt32(temp);

            var team = await _context.Teams.FirstOrDefaultAsync(x => x.UserId == userId);

            GlobalChat chatRecord = new GlobalChat
            {
                ChatText = chatDto.ChatText,
                Username = team.Mascot,
                ChatTime = chatDto.ChatTime
            };

            await _context.GlobalChats.AddAsync(chatRecord);

            return(await _context.SaveChangesAsync() > 0);
        }
コード例 #2
0
        public async Task <IActionResult> SaveChatRecord(GlobalChatDto chatDto)
        {
            var result = await _repo.SaveChatRecord(chatDto);

            return(Ok(result));
        }