แก้บั้กออกคำสั่ง + ใส่ Payload ใน inbox + noti
This commit is contained in:
parent
e451149b2f
commit
356fcba76a
9 changed files with 785 additions and 222 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -1,9 +1,13 @@
|
|||
using BMA.EHR.Application.Common.Interfaces;
|
||||
using BMA.EHR.Application.Responses;
|
||||
using BMA.EHR.Application.Responses.Messages;
|
||||
using BMA.EHR.Domain.Models.HR;
|
||||
using BMA.EHR.Domain.Models.Notifications;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Newtonsoft.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace BMA.EHR.Application.Repositories.MessageQueue
|
||||
{
|
||||
|
|
@ -29,7 +33,7 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
|
|||
|
||||
#region " Methods "
|
||||
|
||||
public async Task<List<Inbox>> GetMyInboxAsync()
|
||||
public async Task<List<InboxResponse>> GetMyInboxAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -44,6 +48,17 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
|
|||
var data = await _dbContext.Set<Inbox>()
|
||||
.Where(x => x.ReceiverUserId == profile.Id)
|
||||
.OrderByDescending(x => x.ReceiveDate)
|
||||
.Select(x => new InboxResponse
|
||||
{
|
||||
Subject = x.Subject,
|
||||
Body = x.Body,
|
||||
ReceiverUserId = x.ReceiverUserId,
|
||||
IsOpen = x.IsOpen,
|
||||
ReceiveDate = x.ReceiveDate,
|
||||
OpenDate = x.OpenDate,
|
||||
Payload = x.Payload == "" ? null : JsonConvert.DeserializeObject<CommandPayload>(Regex.Unescape(x.Payload))
|
||||
})
|
||||
.Take(20)
|
||||
.ToListAsync();
|
||||
|
||||
return data;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,13 @@
|
|||
using BMA.EHR.Application.Common.Interfaces;
|
||||
using BMA.EHR.Application.Responses;
|
||||
using BMA.EHR.Application.Responses.Messages;
|
||||
using BMA.EHR.Domain.Models.HR;
|
||||
using BMA.EHR.Domain.Models.Notifications;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Newtonsoft.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace BMA.EHR.Application.Repositories.MessageQueue
|
||||
{
|
||||
|
|
@ -29,7 +33,7 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
|
|||
|
||||
#region " Methods "
|
||||
|
||||
public async Task<List<Notification>> GetMyNotificationAsync()
|
||||
public async Task<List<NotificationResponse>> GetMyNotificationAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -44,6 +48,17 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
|
|||
var data = await _dbContext.Set<Notification>()
|
||||
.Where(x => x.ReceiverUserId == profile.Id)
|
||||
.OrderByDescending(x => x.ReceiveDate)
|
||||
.Select(x => new NotificationResponse
|
||||
{
|
||||
Body = x.Body,
|
||||
ReceiverUserId = x.ReceiverUserId,
|
||||
IsOpen = x.IsOpen,
|
||||
Type = x.Type,
|
||||
ReceiveDate = x.ReceiveDate,
|
||||
OpenDate = x.OpenDate,
|
||||
Payload = x.Payload == "" ? null : JsonConvert.DeserializeObject<CommandPayload>(Regex.Unescape(x.Payload))
|
||||
})
|
||||
.Take(20)
|
||||
.ToListAsync();
|
||||
|
||||
return data;
|
||||
|
|
|
|||
14
BMA.EHR.Application/Responses/CommandPayload.cs
Normal file
14
BMA.EHR.Application/Responses/CommandPayload.cs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
namespace BMA.EHR.Application.Responses
|
||||
{
|
||||
public class CommandPayload
|
||||
{
|
||||
public List<PayloadAttachment> attachments { get; set; }
|
||||
}
|
||||
|
||||
public class PayloadAttachment
|
||||
{
|
||||
public string name { get; set; }
|
||||
|
||||
public string url { get; set; }
|
||||
}
|
||||
}
|
||||
19
BMA.EHR.Application/Responses/Messages/InboxResponse.cs
Normal file
19
BMA.EHR.Application/Responses/Messages/InboxResponse.cs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
namespace BMA.EHR.Application.Responses.Messages
|
||||
{
|
||||
public class InboxResponse
|
||||
{
|
||||
public string Subject { get; set; } = string.Empty;
|
||||
|
||||
public string Body { get; set; } = string.Empty;
|
||||
|
||||
public Guid ReceiverUserId { get; set; } = Guid.Empty;
|
||||
|
||||
public CommandPayload Payload { get; set; } = new CommandPayload();
|
||||
|
||||
public bool IsOpen { get; set; } = false;
|
||||
|
||||
public DateTime ReceiveDate { get; set; } = DateTime.Now;
|
||||
|
||||
public DateTime? OpenDate { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
namespace BMA.EHR.Application.Responses.Messages
|
||||
{
|
||||
public class NotificationResponse
|
||||
{
|
||||
public string Body { get; set; } = string.Empty;
|
||||
|
||||
public Guid ReceiverUserId { get; set; } = Guid.Empty;
|
||||
|
||||
public string Type { get; set; } = "TEXT";
|
||||
|
||||
public CommandPayload Payload { get; set; } = new();
|
||||
|
||||
public bool IsOpen { get; set; } = false;
|
||||
|
||||
public DateTime ReceiveDate { get; set; } = DateTime.Now;
|
||||
|
||||
public DateTime? OpenDate { get; set; }
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue