api delete noti
This commit is contained in:
parent
e451149b2f
commit
2ba9ef84fd
3 changed files with 137 additions and 0 deletions
|
|
@ -43,6 +43,7 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
|
||||||
|
|
||||||
var data = await _dbContext.Set<Inbox>()
|
var data = await _dbContext.Set<Inbox>()
|
||||||
.Where(x => x.ReceiverUserId == profile.Id)
|
.Where(x => x.ReceiverUserId == profile.Id)
|
||||||
|
.Where(x => x.IsOpen == false)
|
||||||
.OrderByDescending(x => x.ReceiveDate)
|
.OrderByDescending(x => x.ReceiveDate)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
|
|
@ -54,6 +55,46 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task DeleteMyInboxAsync(Guid id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var inbox = await _dbContext.Set<Inbox>()
|
||||||
|
.FirstOrDefaultAsync(p => p.Id == id);
|
||||||
|
|
||||||
|
if (inbox != null)
|
||||||
|
{
|
||||||
|
inbox.IsOpen = true;
|
||||||
|
// _dbContext.Set<Inbox>().Remove(inbox);
|
||||||
|
await _dbContext.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task GetByIdMyInboxAsync(Guid id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var inbox = await _dbContext.Set<Inbox>()
|
||||||
|
.FirstOrDefaultAsync(p => p.Id == id);
|
||||||
|
|
||||||
|
if (inbox != null)
|
||||||
|
{
|
||||||
|
inbox.OpenDate = DateTime.Now;
|
||||||
|
// _dbContext.Set<Inbox>().Remove(inbox);
|
||||||
|
await _dbContext.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
|
||||||
|
|
||||||
var data = await _dbContext.Set<Notification>()
|
var data = await _dbContext.Set<Notification>()
|
||||||
.Where(x => x.ReceiverUserId == profile.Id)
|
.Where(x => x.ReceiverUserId == profile.Id)
|
||||||
|
.Where(x => x.IsOpen == false)
|
||||||
.OrderByDescending(x => x.ReceiveDate)
|
.OrderByDescending(x => x.ReceiveDate)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
|
|
@ -54,6 +55,26 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task DeleteMyNotificationAsync(Guid id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var notification = await _dbContext.Set<Notification>()
|
||||||
|
.FirstOrDefaultAsync(p => p.Id == id);
|
||||||
|
|
||||||
|
if (notification != null)
|
||||||
|
{
|
||||||
|
notification.IsOpen = true;
|
||||||
|
// _dbContext.Set<Notification>().Remove(notification);
|
||||||
|
await _dbContext.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public async Task PushNotificationAsync(Guid ReceiverUserId, string Subject, string Body, string Payload = "", bool IsSendInbox = false, bool IsSendMail = false)
|
public async Task PushNotificationAsync(Guid ReceiverUserId, string Subject, string Body, string Payload = "", bool IsSendInbox = false, bool IsSendMail = false)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,56 @@ namespace BMA.EHR.Command.Service.Controllers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ดูข้อมูล Inbox ของ user ที่ Login
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpGet("my-inboxes/{id:length(36)}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> GetByIdMyInboxAsync(Guid id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _inboxRepository.GetByIdMyInboxAsync(id);
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ลบข้อมูล Inbox ของ user ที่ Login
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpDelete("my-inboxes/{id:length(36)}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> DeleteMyInboxAsync(Guid id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _inboxRepository.DeleteMyInboxAsync(id);
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// แสดงข้อมูล Notification ของ user ที่ Login
|
/// แสดงข้อมูล Notification ของ user ที่ Login
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -84,6 +134,31 @@ namespace BMA.EHR.Command.Service.Controllers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ลบข้อมูล Notification ของ user ที่ Login
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpDelete("my-notifications/{id:length(36)}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> DeleteMyNotificationAsync(Guid id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _notificationRepository.DeleteMyNotificationAsync(id);
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue