public async Task <ChatReportModel> CreateChatReport(ChatReportLogCreationModel reportLogObj)
        {
            ReportLogDAOObject reportLogDAO = Mapper.Map <ReportLogDAOObject>(reportLogObj.Message);
            ChatReportDAO      newReportDAO = new ChatReportDAO()
            {
                ChannelId  = reportLogObj.ChannelId,
                ReportLogs = new List <ReportLogDAOObject>()
                {
                    reportLogDAO
                },
                User = Mapper.Map <ChatUserDAOObject>(reportLogObj.User)
            };

            newReportDAO.Id = await _repoChatReports.CreateItemAsync(newReportDAO);

            if (string.IsNullOrEmpty(newReportDAO.Id))
            {
                throw new Exception($"An error occured when creating a new chat report: {reportLogObj.User.Id}");
            }

            return(Mapper.Map <ChatReportModel>(newReportDAO));
        }
        public async Task <ChatReportModel> CreateOrUpdateChatReport(ChatReportLogCreationModel reportLogObj)
        {
            if (string.IsNullOrEmpty(reportLogObj.User?.Id))
            {
                throw new Exception($"No userId found.");
            }

            ChatReportDAO reportDAO = await _repoChatReports.GetItemAsync(p => p.User.Id == reportLogObj.User.Id && p.EndDate.Value == null);

            //Create
            if (reportDAO == null)
            {
                return(await CreateChatReport(reportLogObj));
            }

            //Update
            ReportLogDAOObject reportLogDAO = Mapper.Map <ReportLogDAOObject>(reportLogObj.Message);

            reportDAO.ReportLogs.Add(reportLogDAO);

            try
            {
                await _repoChatReports.UpdateItemAsync(reportDAO);
            }
            catch (DocumentClientException e)
            {
                //Update concurrency issue, retrying
                if (e.StatusCode == HttpStatusCode.PreconditionFailed)
                {
                    return(await CreateOrUpdateChatReport(reportLogObj));
                }
                throw e;
            }

            return(Mapper.Map <ChatReportModel>(reportDAO));
        }