...
This commit is contained in:
@@ -8,6 +8,7 @@ using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -166,22 +167,39 @@ namespace Hushian.Application.Services
|
||||
ConversationResponses = new List<ConversationResponse>() { new() { Text = dto.Question, Type = type } }
|
||||
};
|
||||
var mi = await _ConversationRepository.ADD(conversation);
|
||||
Response.Value = new ChatItemDto()
|
||||
{
|
||||
ID = mi.ID,
|
||||
ExperID = mi.ConversationResponses.OrderBy(o => o.ID).Last().ExperID,
|
||||
ExperFullName = /*mi.ConversationResponses.OrderBy(o => o.ID).Last().Exper.FullName*/ "",
|
||||
GroupID = mi.GroupID,
|
||||
GroupName = /*mi.Group.Name*/ "",
|
||||
LastText = mi.ConversationResponses.OrderBy(o => o.ID).Last().Text,
|
||||
LastMsgdate = mi.Cdatetime.GetDatePersian(),
|
||||
LastMsgtime = mi.Cdatetime.GetTime(),
|
||||
LastMsgType = mi.ConversationResponses.OrderBy(o => o.ID).Last().Type,
|
||||
status = mi.Status,
|
||||
UserID = mi.UserID,
|
||||
UserFullName = /*string.IsNullOrEmpty(mi.User.FullName) ? mi.User.Mobile : mi.User.FullName*/ ""
|
||||
if(mi.ID > 0)
|
||||
Response.Value = await _ConversationRepository.Get()
|
||||
.Include(inc => inc.Group).Include(inc => inc.ConversationResponses).ThenInclude(tinc => tinc.Exper)
|
||||
.Where(w => w.ID==mi.ID)
|
||||
.Select(s => new ChatItemDto()
|
||||
{
|
||||
ID = s.ID,
|
||||
ExperID = s.ConversationResponses.OrderBy(o => o.ID).Last().ExperID,
|
||||
ExperFullName = s.ConversationResponses.OrderBy(o => o.ID).Last().Exper.FullName,
|
||||
GroupID = s.GroupID,
|
||||
GroupName = s.Group.Name,
|
||||
LastText = s.ConversationResponses.OrderBy(o => o.ID).Last().Text,
|
||||
LastMsgdate = s.Cdatetime.GetDatePersian(),
|
||||
LastMsgtime = s.Cdatetime.GetTime(),
|
||||
LastMsgType = s.ConversationResponses.OrderBy(o => o.ID).Last().Type,
|
||||
status = s.Status,
|
||||
UserID = s.UserID,
|
||||
UserFullName = string.IsNullOrEmpty(s.User.FullName) ? s.User.Mobile : s.User.FullName,
|
||||
Responses = s.ConversationResponses.Select(ss => new ChatItemResponseDto()
|
||||
{
|
||||
ChatItemID = ss.ConversationID,
|
||||
ExperID = ss.ExperID,
|
||||
ExperName = ss.Exper.FullName,
|
||||
FileContent = ss.FileContent,
|
||||
FileName = ss.FileName,
|
||||
FileType = ss.FileType,
|
||||
ID = ss.ID,
|
||||
IsRead = ss.IsRead,
|
||||
text = ss.Text,
|
||||
Type = ss.Type
|
||||
}).ToList()
|
||||
|
||||
};
|
||||
}).FirstOrDefaultAsync();
|
||||
Response.Success = mi.ID > 0;
|
||||
}
|
||||
else Response.Errors.Add("شناسه گروه صحیح نمی باشد");
|
||||
@@ -305,7 +323,49 @@ namespace Hushian.Application.Services
|
||||
Response.Value= await _ConversationRepository.Get()
|
||||
.Include(inc => inc.Group)
|
||||
.Include(inc => inc.ConversationResponses).ThenInclude(tinc => tinc.Exper)
|
||||
.Where(w => w.UserID== UserID && w.Status != ConversationStatus.Finished)
|
||||
.Where(w => w.UserID== UserID &&w.CompanyID==CompanyID && w.Status != ConversationStatus.Finished)
|
||||
.OrderByDescending(o=>o.ID)
|
||||
.Select(s => new ChatItemDto()
|
||||
{
|
||||
ID = s.ID,
|
||||
ExperID = s.ConversationResponses.OrderBy(o => o.ID).Last().ExperID,
|
||||
ExperFullName = s.ConversationResponses.OrderBy(o => o.ID).Last().Exper.FullName,
|
||||
GroupID = s.GroupID,
|
||||
GroupName = s.Group.Name,
|
||||
LastText = s.ConversationResponses.OrderBy(o => o.ID).Last().Text,
|
||||
LastMsgdate = s.Cdatetime.GetDatePersian(),
|
||||
LastMsgtime = s.Cdatetime.GetTime(),
|
||||
LastMsgType = s.ConversationResponses.OrderBy(o => o.ID).Last().Type,
|
||||
status = s.Status,
|
||||
UserID = s.UserID,
|
||||
UserFullName = string.IsNullOrEmpty(s.User.FullName) ? s.User.Mobile : s.User.FullName,
|
||||
Responses = s.ConversationResponses.Select(ss => new ChatItemResponseDto()
|
||||
{
|
||||
ChatItemID = ss.ConversationID,
|
||||
ExperID = ss.ExperID,
|
||||
ExperName = ss.Exper.FullName,
|
||||
FileContent = ss.FileContent,
|
||||
FileName = ss.FileName,
|
||||
FileType = ss.FileType,
|
||||
ID = ss.ID,
|
||||
IsRead = ss.IsRead,
|
||||
text = ss.Text,
|
||||
Type = ss.Type
|
||||
}).ToList()
|
||||
|
||||
}).FirstOrDefaultAsync();
|
||||
|
||||
if (Response.Value != null) Response.Success = true;
|
||||
return Response;
|
||||
}
|
||||
public async Task<ResponseBase<ChatItemDto>> GetChat(int ChatID, int UserID)
|
||||
{
|
||||
ResponseBase<ChatItemDto> Response = new();
|
||||
Response.Value = await _ConversationRepository.Get()
|
||||
.Include(inc => inc.Group)
|
||||
.Include(inc => inc.ConversationResponses).ThenInclude(tinc => tinc.Exper)
|
||||
.Where(w => w.UserID == UserID && w.ID == ChatID )
|
||||
.OrderByDescending(o => o.ID)
|
||||
.Select(s => new ChatItemDto()
|
||||
{
|
||||
ID = s.ID,
|
||||
|
Reference in New Issue
Block a user