...
This commit is contained in:
@@ -5,7 +5,8 @@ namespace Common.Dtos.Conversation
|
|||||||
public class Read_ConversationDto
|
public class Read_ConversationDto
|
||||||
{
|
{
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
public string Title { get; set; }
|
public string LastText { get; set; }
|
||||||
|
public ConversationType LastMsgType { get; set; }
|
||||||
public ConversationStatus status { get; set; }
|
public ConversationStatus status { get; set; }
|
||||||
|
|
||||||
public int? GroupID { get; set; }
|
public int? GroupID { get; set; }
|
||||||
@@ -17,8 +18,8 @@ namespace Common.Dtos.Conversation
|
|||||||
public int? ExperID { get; set; }
|
public int? ExperID { get; set; }
|
||||||
public string? ExperFullName { get; set; }
|
public string? ExperFullName { get; set; }
|
||||||
|
|
||||||
public string Cdate { get; set; }
|
public string LastMsgdate { get; set; }
|
||||||
public string Ctime { get; set; }
|
public string LastMsgtime { get; set; }
|
||||||
public int NoReadCount { get; set; } = 0;
|
public int NoReadCount { get; set; } = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -93,13 +93,89 @@ namespace Hushian.Application.Services
|
|||||||
|
|
||||||
return Response;
|
return Response;
|
||||||
}
|
}
|
||||||
public async Task<List<Read_ConversationDto>> MyConversation(int CompanyID, string UserID)
|
public async Task<List<Read_ConversationDto>> MyConversation(int UserID)
|
||||||
{ return new(); }
|
=> await _ConversationRepository.Get()
|
||||||
public async Task<List<Read_ConversationDto>> MyConversationIsFinished(int CompanyID, string? ExperID = null)
|
.Include(inc => inc.Group)
|
||||||
{ return new(); }
|
.Include(inc => inc.ConversationResponses).ThenInclude(tinc => tinc.Exper)
|
||||||
public async Task<List<Read_ConversationDto>> MyConversationIsInProgress(int CompanyID, string ExperID)
|
.Where(w => w.UserID == UserID)
|
||||||
{ return new(); }
|
.Select(s => new Read_ConversationDto()
|
||||||
public async Task<List<Read_ConversationDto>> ConversationAwaitingOurResponse(int CompanyID, string? ExperID = null)
|
{
|
||||||
{ return new(); }
|
ExperID = s.ConversationResponses.Last().ExperID,
|
||||||
|
ExperFullName = s.ConversationResponses.Last().Exper.FullName,
|
||||||
|
GroupID = s.GroupID,
|
||||||
|
GroupName = s.Group.Name,
|
||||||
|
LastText = s.ConversationResponses.Last().Text,
|
||||||
|
LastMsgdate = s.Cdatetime.GetDatePersian(),
|
||||||
|
LastMsgtime = s.Cdatetime.GetTime(),
|
||||||
|
LastMsgType = s.ConversationResponses.Last().Type,
|
||||||
|
NoReadCount = s.ConversationResponses.Count(c => !c.IsRead),
|
||||||
|
status = s.Status,
|
||||||
|
UserID = s.UserID,
|
||||||
|
UserFullName = s.User.FullName
|
||||||
|
|
||||||
|
}).ToListAsync();
|
||||||
|
public async Task<List<Read_ConversationDto>> MyConversationIsFinished(int ExperID)
|
||||||
|
=> await _ConversationRepository.Get()
|
||||||
|
.Include(inc => inc.Group)
|
||||||
|
.Include(inc => inc.ConversationResponses).ThenInclude(tinc => tinc.Exper)
|
||||||
|
.Where(w => w.ConversationResponses.Any(a=>a.ExperID==ExperID) && w.Status==ConversationStatus.Finished)
|
||||||
|
.Select(s => new Read_ConversationDto()
|
||||||
|
{
|
||||||
|
ExperID = s.ConversationResponses.Last().ExperID,
|
||||||
|
ExperFullName = s.ConversationResponses.Last().Exper.FullName,
|
||||||
|
GroupID = s.GroupID,
|
||||||
|
GroupName = s.Group.Name,
|
||||||
|
LastText = s.ConversationResponses.Last().Text,
|
||||||
|
LastMsgdate = s.Cdatetime.GetDatePersian(),
|
||||||
|
LastMsgtime = s.Cdatetime.GetTime(),
|
||||||
|
LastMsgType = s.ConversationResponses.Last().Type,
|
||||||
|
NoReadCount = s.ConversationResponses.Count(c => !c.IsRead),
|
||||||
|
status = s.Status,
|
||||||
|
UserID = s.UserID,
|
||||||
|
UserFullName = s.User.FullName
|
||||||
|
|
||||||
|
}).ToListAsync();
|
||||||
|
public async Task<List<Read_ConversationDto>> MyConversationIsInProgress(int ExperID)
|
||||||
|
=> await _ConversationRepository.Get()
|
||||||
|
.Include(inc => inc.Group)
|
||||||
|
.Include(inc => inc.ConversationResponses).ThenInclude(tinc => tinc.Exper)
|
||||||
|
.Where(w => w.ConversationResponses.Any(a => a.ExperID == ExperID) && w.Status == ConversationStatus.InProgress)
|
||||||
|
.Select(s => new Read_ConversationDto()
|
||||||
|
{
|
||||||
|
ExperID = s.ConversationResponses.Last().ExperID,
|
||||||
|
ExperFullName = s.ConversationResponses.Last().Exper.FullName,
|
||||||
|
GroupID = s.GroupID,
|
||||||
|
GroupName = s.Group.Name,
|
||||||
|
LastText = s.ConversationResponses.Last().Text,
|
||||||
|
LastMsgdate = s.Cdatetime.GetDatePersian(),
|
||||||
|
LastMsgtime = s.Cdatetime.GetTime(),
|
||||||
|
LastMsgType = s.ConversationResponses.Last().Type,
|
||||||
|
NoReadCount = s.ConversationResponses.Count(c => !c.IsRead),
|
||||||
|
status = s.Status,
|
||||||
|
UserID = s.UserID,
|
||||||
|
UserFullName = s.User.FullName
|
||||||
|
|
||||||
|
}).ToListAsync();
|
||||||
|
public async Task<List<Read_ConversationDto>> ConversationAwaitingOurResponse(int CompanyID)
|
||||||
|
=> await _ConversationRepository.Get()
|
||||||
|
.Include(inc => inc.Group)
|
||||||
|
.Include(inc => inc.ConversationResponses).ThenInclude(tinc => tinc.Exper)
|
||||||
|
.Where(w => w.ConversationResponses.Any(a => !a.ExperID.HasValue) && w.CompanyID == CompanyID)
|
||||||
|
.Select(s => new Read_ConversationDto()
|
||||||
|
{
|
||||||
|
ExperID = s.ConversationResponses.Last().ExperID,
|
||||||
|
ExperFullName = s.ConversationResponses.Last().Exper.FullName,
|
||||||
|
GroupID = s.GroupID,
|
||||||
|
GroupName = s.Group.Name,
|
||||||
|
LastText = s.ConversationResponses.Last().Text,
|
||||||
|
LastMsgdate = s.Cdatetime.GetDatePersian(),
|
||||||
|
LastMsgtime = s.Cdatetime.GetTime(),
|
||||||
|
LastMsgType = s.ConversationResponses.Last().Type,
|
||||||
|
NoReadCount = s.ConversationResponses.Count(c => !c.IsRead),
|
||||||
|
status = s.Status,
|
||||||
|
UserID = s.UserID,
|
||||||
|
UserFullName = s.User.FullName
|
||||||
|
|
||||||
|
}).ToListAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
22
Hushian.Application/Services/ExMethod.cs
Normal file
22
Hushian.Application/Services/ExMethod.cs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Hushian.Application.Services
|
||||||
|
{
|
||||||
|
public static class ExMethod
|
||||||
|
{
|
||||||
|
public static string GetDatePersian(this DateTime d)
|
||||||
|
{
|
||||||
|
PersianCalendar pc = new PersianCalendar();
|
||||||
|
return string.Format("{0}/{1}/{2}", pc.GetYear(d), pc.GetMonth(d), pc.GetDayOfMonth(d));
|
||||||
|
}
|
||||||
|
public static string GetTime(this DateTime d)
|
||||||
|
{
|
||||||
|
return d.Hour.ToString() + ":" + d.Minute.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user