#72 removing RUserNotificationViewModel constructor
This commit is contained in:
parent
04f35d614f
commit
d015f2f641
@ -7,18 +7,6 @@ namespace RSecurityBackend.Models.Notification.ViewModels
|
||||
/// </summary>
|
||||
public class RUserNotificationViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
/// <param name="src"></param>
|
||||
public RUserNotificationViewModel(RUserNotification src)
|
||||
{
|
||||
Id = src.Id;
|
||||
DateTime = src.DateTime;
|
||||
Status = src.Status;
|
||||
Subject = src.Subject;
|
||||
HtmlText = src.HtmlText;
|
||||
}
|
||||
/// <summary>
|
||||
/// Id
|
||||
/// </summary>
|
||||
|
||||
@ -2009,12 +2009,6 @@
|
||||
User Notification
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:RSecurityBackend.Models.Notification.ViewModels.RUserNotificationViewModel.#ctor(RSecurityBackend.Models.Notification.RUserNotification)">
|
||||
<summary>
|
||||
constructor
|
||||
</summary>
|
||||
<param name="src"></param>
|
||||
</member>
|
||||
<member name="P:RSecurityBackend.Models.Notification.ViewModels.RUserNotificationViewModel.Id">
|
||||
<summary>
|
||||
Id
|
||||
|
||||
@ -38,7 +38,17 @@ namespace RSecurityBackend.Services.Implementation
|
||||
};
|
||||
_context.Notifications.Add(notification);
|
||||
await _context.SaveChangesAsync();
|
||||
return new RServiceResult<RUserNotificationViewModel>(new RUserNotificationViewModel(notification));
|
||||
return new RServiceResult<RUserNotificationViewModel>
|
||||
(
|
||||
new RUserNotificationViewModel()
|
||||
{
|
||||
Id = notification.Id,
|
||||
DateTime = notification.DateTime,
|
||||
Status = notification.Status,
|
||||
Subject = notification.Subject,
|
||||
HtmlText = notification.HtmlText
|
||||
}
|
||||
);
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
@ -61,7 +71,18 @@ namespace RSecurityBackend.Services.Implementation
|
||||
notification.Status = notification.Status == NotificationStatus.Unread ? NotificationStatus.Read : NotificationStatus.Unread;
|
||||
_context.Notifications.Update(notification);
|
||||
await _context.SaveChangesAsync();
|
||||
return new RServiceResult<RUserNotificationViewModel>(new RUserNotificationViewModel(notification));
|
||||
return new RServiceResult<RUserNotificationViewModel>
|
||||
(
|
||||
new RUserNotificationViewModel()
|
||||
{
|
||||
Id = notification.Id,
|
||||
DateTime = notification.DateTime,
|
||||
Status = notification.Status,
|
||||
Subject = notification.Subject,
|
||||
HtmlText = notification.HtmlText
|
||||
}
|
||||
|
||||
);
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
@ -139,9 +160,18 @@ namespace RSecurityBackend.Services.Implementation
|
||||
return new RServiceResult<RUserNotificationViewModel[]>
|
||||
(
|
||||
await _context.Notifications
|
||||
.Where(n => n.UserId == userId)
|
||||
.OrderByDescending(n => n.DateTime)
|
||||
.Select(n => new RUserNotificationViewModel(n))
|
||||
.Where(notification => notification.UserId == userId)
|
||||
.OrderByDescending(notification => notification.DateTime)
|
||||
.Select(notification =>
|
||||
new RUserNotificationViewModel()
|
||||
{
|
||||
Id = notification.Id,
|
||||
DateTime = notification.DateTime,
|
||||
Status = notification.Status,
|
||||
Subject = notification.Subject,
|
||||
HtmlText = notification.HtmlText
|
||||
}
|
||||
)
|
||||
.ToArrayAsync()
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user