api delete noti

This commit is contained in:
Kittapath 2023-09-11 12:02:01 +07:00
parent e451149b2f
commit 2ba9ef84fd
3 changed files with 137 additions and 0 deletions

View file

@ -43,6 +43,7 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
var data = await _dbContext.Set<Inbox>()
.Where(x => x.ReceiverUserId == profile.Id)
.Where(x => x.IsOpen == false)
.OrderByDescending(x => x.ReceiveDate)
.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
}
}