public async Task <IActionResult> PutChatSession([FromRoute] int id, [FromBody] ChatSession chatSession)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != chatSession.ChatSessionId)
            {
                return(BadRequest());
            }

            try
            {
                await _chatSessionService.Update(chatSession);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!(await ChatSessionExists(id)))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #2
0
        private async Task SaveSessionDataAsync(IRestChatSession session)
        {
            if (await _chatSessionService.Exists(s => s.ChatSessionId == session.Id))
            {
                Domain.ChatSession dbChatSession = await _chatSessionService.FindBy(s => s.ChatSessionId == session.Id);

                dbChatSession.Data = JsonConvert.SerializeObject(session.SessionStorage.Values);
                await _chatSessionService.Update(dbChatSession);
            }
        }