read not
This commit is contained in:
@@ -7,14 +7,27 @@ namespace Back.Services
|
||||
public class servNotification
|
||||
{
|
||||
private readonly IAsyncRepository<Notification> _NotificationRepo;
|
||||
|
||||
public servNotification(IAsyncRepository<Notification> NotificationRepo)
|
||||
private readonly IAsyncRepository<UserNotfi> _UserNotfiRepo;
|
||||
public servNotification(IAsyncRepository<Notification> NotificationRepo, IAsyncRepository<UserNotfi> userNotfiRepo)
|
||||
{
|
||||
_NotificationRepo = NotificationRepo;
|
||||
_UserNotfiRepo = userNotfiRepo;
|
||||
}
|
||||
public async Task<List<Notification>> GetNotifications()
|
||||
public async Task<bool> ReadNotification(int UserID,int ntID)
|
||||
{
|
||||
return await _NotificationRepo.Get(w=>w.Status).ToListAsync();
|
||||
if (!await _UserNotfiRepo.Get(w => w.UserID == UserID && w.NotificationID == ntID).AnyAsync())
|
||||
return await _UserNotfiRepo.AddBoolResultAsync(new UserNotfi
|
||||
{
|
||||
NotificationID = ntID,
|
||||
UserID = UserID,
|
||||
});
|
||||
else return true;
|
||||
}
|
||||
public async Task<List<Notification>> GetNotifications(int UserID)
|
||||
{
|
||||
var readmsg=await _UserNotfiRepo.Get(w => w.UserID == UserID).Select(s=>s.NotificationID).ToListAsync();
|
||||
|
||||
return await _NotificationRepo.Get(w=>(string.IsNullOrEmpty(w.ForUser) || w.ForUser.Contains("/"+UserID.ToString()+"/"))&& !readmsg.Contains(w.ID)).ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -244,14 +244,14 @@ namespace Back.Services
|
||||
request.Warning.Add(new AlertDTO { Status = 5, Message = "بهتر است اطلاعات شرکت بروزرسانی شود" });
|
||||
}
|
||||
}
|
||||
var nots = await _servNotification.GetNotifications();
|
||||
var nots = await _servNotification.GetNotifications(UserID);
|
||||
if (nots.Any())
|
||||
request.Notifications = nots.Select(s => new AlertDTO
|
||||
{
|
||||
ViewSize=s.ID.ToString(),
|
||||
Message = s.Message,
|
||||
Status = s.Type,
|
||||
Path = s.Path,
|
||||
ViewSize = s.ViewSize
|
||||
Path = s.Title
|
||||
}).ToList();
|
||||
|
||||
LastActivitySevice lastInvoice = new LastActivitySevice();
|
||||
|
Reference in New Issue
Block a user