...
This commit is contained in:
@@ -61,7 +61,8 @@ namespace Hushian.Application.Services
|
|||||||
GroupID = dto.GroupID,
|
GroupID = dto.GroupID,
|
||||||
ConversationResponses = new List<ConversationResponse>() { new() { Text = dto.Question, Type = type } }
|
ConversationResponses = new List<ConversationResponse>() { new() { Text = dto.Question, Type = type } }
|
||||||
};
|
};
|
||||||
Response.Value = (await _ConversationRepository.ADD(conversation)).ID;
|
var mi = await _ConversationRepository.ADD(conversation);
|
||||||
|
Response.Value = mi.ID;
|
||||||
Response.Success = Response.Value > 0;
|
Response.Success = Response.Value > 0;
|
||||||
}
|
}
|
||||||
else Response.Errors.Add("شناسه گروه صحیح نمی باشد");
|
else Response.Errors.Add("شناسه گروه صحیح نمی باشد");
|
||||||
@@ -139,7 +140,7 @@ namespace Hushian.Application.Services
|
|||||||
NoReadCount = s.ConversationResponses.Count(c => !c.IsRead),
|
NoReadCount = s.ConversationResponses.Count(c => !c.IsRead),
|
||||||
status = s.Status,
|
status = s.Status,
|
||||||
UserID = s.UserID,
|
UserID = s.UserID,
|
||||||
UserFullName = s.User.FullName
|
UserFullName = string.IsNullOrEmpty(s.User.FullName) ? s.User.Mobile : s.User.FullName
|
||||||
|
|
||||||
}).ToListAsync();
|
}).ToListAsync();
|
||||||
public async Task<List<Read_ConversationResponseDto>> GetConversationItems(int ConversationID)
|
public async Task<List<Read_ConversationResponseDto>> GetConversationItems(int ConversationID)
|
||||||
@@ -170,6 +171,7 @@ namespace Hushian.Application.Services
|
|||||||
.Where(w => w.ConversationResponses.Any(a => a.ExperID == ExperID) && w.Status == status)
|
.Where(w => w.ConversationResponses.Any(a => a.ExperID == ExperID) && w.Status == status)
|
||||||
.Select(s => new Read_ConversationDto()
|
.Select(s => new Read_ConversationDto()
|
||||||
{
|
{
|
||||||
|
ID=s.ID,
|
||||||
ExperID = s.ConversationResponses.OrderBy(o => o.ID).Last().ExperID,
|
ExperID = s.ConversationResponses.OrderBy(o => o.ID).Last().ExperID,
|
||||||
ExperFullName = s.ConversationResponses.OrderBy(o => o.ID).Last().Exper.FullName,
|
ExperFullName = s.ConversationResponses.OrderBy(o => o.ID).Last().Exper.FullName,
|
||||||
GroupID = s.GroupID,
|
GroupID = s.GroupID,
|
||||||
@@ -181,7 +183,7 @@ namespace Hushian.Application.Services
|
|||||||
NoReadCount = s.ConversationResponses.Count(c => !c.IsRead),
|
NoReadCount = s.ConversationResponses.Count(c => !c.IsRead),
|
||||||
status = s.Status,
|
status = s.Status,
|
||||||
UserID = s.UserID,
|
UserID = s.UserID,
|
||||||
UserFullName = s.User.FullName
|
UserFullName = string.IsNullOrEmpty(s.User.FullName) ? s.User.Mobile : s.User.FullName
|
||||||
|
|
||||||
}).ToListAsync();
|
}).ToListAsync();
|
||||||
public async Task<List<Read_ConversationDto>> GetConversationByCompanyID(int CompanyID, ConversationStatus status)
|
public async Task<List<Read_ConversationDto>> GetConversationByCompanyID(int CompanyID, ConversationStatus status)
|
||||||
@@ -191,6 +193,7 @@ namespace Hushian.Application.Services
|
|||||||
.Where(w => w.CompanyID==CompanyID && w.Status ==status)
|
.Where(w => w.CompanyID==CompanyID && w.Status ==status)
|
||||||
.Select(s => new Read_ConversationDto()
|
.Select(s => new Read_ConversationDto()
|
||||||
{
|
{
|
||||||
|
ID = s.ID,
|
||||||
ExperID = s.ConversationResponses.OrderBy(o => o.ID).Last().ExperID,
|
ExperID = s.ConversationResponses.OrderBy(o => o.ID).Last().ExperID,
|
||||||
ExperFullName = s.ConversationResponses.OrderBy(o => o.ID).Last().Exper.FullName,
|
ExperFullName = s.ConversationResponses.OrderBy(o => o.ID).Last().Exper.FullName,
|
||||||
GroupID = s.GroupID,
|
GroupID = s.GroupID,
|
||||||
@@ -202,7 +205,7 @@ namespace Hushian.Application.Services
|
|||||||
NoReadCount = s.ConversationResponses.Count(c => !c.IsRead),
|
NoReadCount = s.ConversationResponses.Count(c => !c.IsRead),
|
||||||
status = s.Status,
|
status = s.Status,
|
||||||
UserID = s.UserID,
|
UserID = s.UserID,
|
||||||
UserFullName = s.User.FullName
|
UserFullName = string.IsNullOrEmpty(s.User.FullName) ? s.User.Mobile : s.User.FullName
|
||||||
|
|
||||||
}).ToListAsync();
|
}).ToListAsync();
|
||||||
public async Task<List<Read_ConversationDto>> ConversationAwaitingOurResponse(int CompanyID)
|
public async Task<List<Read_ConversationDto>> ConversationAwaitingOurResponse(int CompanyID)
|
||||||
@@ -212,6 +215,7 @@ namespace Hushian.Application.Services
|
|||||||
.Where(w => w.Status== ConversationStatus.Recorded && w.CompanyID == CompanyID)
|
.Where(w => w.Status== ConversationStatus.Recorded && w.CompanyID == CompanyID)
|
||||||
.Select(s => new Read_ConversationDto()
|
.Select(s => new Read_ConversationDto()
|
||||||
{
|
{
|
||||||
|
ID = s.ID,
|
||||||
ExperID = s.ConversationResponses.OrderBy(o=>o.ID).Last().ExperID,
|
ExperID = s.ConversationResponses.OrderBy(o=>o.ID).Last().ExperID,
|
||||||
ExperFullName = s.ConversationResponses.OrderBy(o => o.ID).Last().Exper.FullName,
|
ExperFullName = s.ConversationResponses.OrderBy(o => o.ID).Last().Exper.FullName,
|
||||||
GroupID = s.GroupID,
|
GroupID = s.GroupID,
|
||||||
@@ -223,7 +227,7 @@ namespace Hushian.Application.Services
|
|||||||
NoReadCount = s.ConversationResponses.Count(c => !c.IsRead),
|
NoReadCount = s.ConversationResponses.Count(c => !c.IsRead),
|
||||||
status = s.Status,
|
status = s.Status,
|
||||||
UserID = s.UserID,
|
UserID = s.UserID,
|
||||||
UserFullName = s.User.FullName
|
UserFullName = string.IsNullOrEmpty(s.User.FullName) ? s.User.Mobile : s.User.FullName
|
||||||
|
|
||||||
}).ToListAsync();
|
}).ToListAsync();
|
||||||
public async Task<bool> FinishConversation(int ConversationID)
|
public async Task<bool> FinishConversation(int ConversationID)
|
||||||
|
@@ -24,7 +24,7 @@ namespace Hushian.Persistence.Repositories
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
await _context.AddAsync(entity);
|
await _context.AddAsync(entity);
|
||||||
if ((await _context.SaveChangesAsync() == 1))
|
if ((await _context.SaveChangesAsync() >= 1))
|
||||||
return entity;
|
return entity;
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@@ -25,7 +25,7 @@ namespace Hushian.WebApi.Controllers.v1
|
|||||||
|
|
||||||
[HttpPost("MyConversation")]
|
[HttpPost("MyConversation")]
|
||||||
[Authorize(Roles = "Company,Exper")]
|
[Authorize(Roles = "Company,Exper")]
|
||||||
public async Task<ActionResult> MyConversation(ConversationStatus status)
|
public async Task<ActionResult> MyConversation([FromBody]ConversationStatus status)
|
||||||
{
|
{
|
||||||
if (User.IsInRole("Exper"))
|
if (User.IsInRole("Exper"))
|
||||||
{
|
{
|
||||||
@@ -76,7 +76,7 @@ namespace Hushian.WebApi.Controllers.v1
|
|||||||
[HttpPost("NewConversationFromCurrentUser")]
|
[HttpPost("NewConversationFromCurrentUser")]
|
||||||
public async Task<ActionResult> NewConversationFromCurrentUser(ADD_ConversationDto conversation)
|
public async Task<ActionResult> NewConversationFromCurrentUser(ADD_ConversationDto conversation)
|
||||||
{
|
{
|
||||||
string UserID = User.Claims.Where(w => w.Type == CustomClaimTypes.Uid).Select(s => s.Value).First();
|
conversation.UserID = User.Claims.Where(w => w.Type == CustomClaimTypes.Uid).Select(s => Convert.ToInt32( s.Value)).First();
|
||||||
var response = await _conversationService.NewConversation(conversation);
|
var response = await _conversationService.NewConversation(conversation);
|
||||||
return response.Success ? Ok(response.Value)
|
return response.Success ? Ok(response.Value)
|
||||||
: BadRequest(response.Errors);
|
: BadRequest(response.Errors);
|
||||||
@@ -156,7 +156,7 @@ namespace Hushian.WebApi.Controllers.v1
|
|||||||
{
|
{
|
||||||
string strUserID = User.Claims.Where(w => w.Type == CustomClaimTypes.Uid).Select(s => s.Value).First();
|
string strUserID = User.Claims.Where(w => w.Type == CustomClaimTypes.Uid).Select(s => s.Value).First();
|
||||||
int UserID = Convert.ToInt32(strUserID);
|
int UserID = Convert.ToInt32(strUserID);
|
||||||
var response = await _conversationService.GEtConversation(CompanyID, UserID);
|
var response = await _conversationService.GEtConversation(UserID,CompanyID );
|
||||||
return Ok(response) ;
|
return Ok(response) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -22,7 +22,7 @@
|
|||||||
VisuallyHiddenText="unread messages">@item.NoReadCount </Badge>
|
VisuallyHiddenText="unread messages">@item.NoReadCount </Badge>
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -239,11 +239,11 @@
|
|||||||
@functions{
|
@functions{
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
Role = await localStorageService.GetItem<string>("Role");
|
Role = await localStorageService.GetItem<string>("C/Role");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
UserID= await localStorageService.GetItem<int>("UserID");
|
UserID= await localStorageService.GetItem<int>("C/UserID");
|
||||||
convloading = true;
|
convloading = true;
|
||||||
await LoadSessionB();
|
await LoadSessionB();
|
||||||
Inbox1Items =await conversationService.ConversationAwaitingOurResponse();
|
Inbox1Items =await conversationService.ConversationAwaitingOurResponse();
|
||||||
|
@@ -180,17 +180,17 @@
|
|||||||
CompanyID=CompanyID
|
CompanyID=CompanyID
|
||||||
OnMultipleOfThree="EventCallback.Factory.Create<int>(this, CallBackSelectedGroup)" />
|
OnMultipleOfThree="EventCallback.Factory.Create<int>(this, CallBackSelectedGroup)" />
|
||||||
;
|
;
|
||||||
Conversations = await conversationService.MyConversationUserSide(CompanyID);
|
|
||||||
if (Conversations.Count > 0)
|
|
||||||
ConversationsContent =@<ConversionHistoryComponent Conversations="Conversations"
|
|
||||||
OnMultipleOfThree="EventCallback.Factory.Create<int>(this, SelectedConv)" />
|
|
||||||
;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// ex Groups Company
|
// ex Groups Company
|
||||||
}
|
}
|
||||||
|
Conversations = await conversationService.MyConversationUserSide(CompanyID);
|
||||||
|
if (Conversations.Count > 0)
|
||||||
|
ConversationsContent =@<ConversionHistoryComponent Conversations="Conversations"
|
||||||
|
OnMultipleOfThree="EventCallback.Factory.Create<int>(this, SelectedConv)" />
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -235,7 +235,15 @@
|
|||||||
GroupID = SelectedGroup,
|
GroupID = SelectedGroup,
|
||||||
Question = InputMessage
|
Question = InputMessage
|
||||||
};
|
};
|
||||||
|
var convID= await conversationService.NewConversationFromCurrentUser(Item);
|
||||||
|
if (convID >0)
|
||||||
|
{
|
||||||
|
ConversationID = convID;
|
||||||
|
await SelectedConv(ConversationID.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
InputMessage = string.Empty;
|
||||||
Sending = false;
|
Sending = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
using Common.Dtos.Conversation;
|
using Common.Dtos.Conversation;
|
||||||
using Common.Enums;
|
using Common.Enums;
|
||||||
|
using System.ComponentModel.Design;
|
||||||
using System.Net.Http.Json;
|
using System.Net.Http.Json;
|
||||||
|
|
||||||
namespace HushianWebApp.Service
|
namespace HushianWebApp.Service
|
||||||
@@ -82,5 +83,13 @@ namespace HushianWebApp.Service
|
|||||||
|
|
||||||
return new();
|
return new();
|
||||||
}
|
}
|
||||||
|
public async Task<int> NewConversationFromCurrentUser(ADD_ConversationDto conversation)
|
||||||
|
{
|
||||||
|
var response = await _baseController.Post($"{BaseRoute}NewConversationFromCurrentUser", conversation);
|
||||||
|
if (response.IsSuccessStatusCode)
|
||||||
|
return await response.Content.ReadFromJsonAsync<int>();
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user