...
This commit is contained in:
@@ -93,13 +93,89 @@ namespace Hushian.Application.Services
|
||||
|
||||
return Response;
|
||||
}
|
||||
public async Task<List<Read_ConversationDto>> MyConversation(int CompanyID, string UserID)
|
||||
{ return new(); }
|
||||
public async Task<List<Read_ConversationDto>> MyConversationIsFinished(int CompanyID, string? ExperID = null)
|
||||
{ return new(); }
|
||||
public async Task<List<Read_ConversationDto>> MyConversationIsInProgress(int CompanyID, string ExperID)
|
||||
{ return new(); }
|
||||
public async Task<List<Read_ConversationDto>> ConversationAwaitingOurResponse(int CompanyID, string? ExperID = null)
|
||||
{ return new(); }
|
||||
public async Task<List<Read_ConversationDto>> MyConversation(int UserID)
|
||||
=> await _ConversationRepository.Get()
|
||||
.Include(inc => inc.Group)
|
||||
.Include(inc => inc.ConversationResponses).ThenInclude(tinc => tinc.Exper)
|
||||
.Where(w => w.UserID == UserID)
|
||||
.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>> 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