DocSas/PropertyService.Domain/ModelView/Notifications/NotificationProvider.cs
/// <summary>
/// get notifications as an asynchronous operation.
/// </summary>
/// <param name="userId">The user identifier.</param>
/// <param name="propertyId">The property identifier.</param>
/// <param name="isMainPageView">if set to <c>true</c> [is main page view].</param>
/// <returns>Task&lt;DSCResponse&gt;.</returns>
get notifications as an asynchronous operation.
get notifications as an asynchronous operation .
public async Task<DSCResponse> GetNotificationsAsync(Guid userId, Guid propertyId, bool isMainPageView = false)
        {
            var msg = new Dictionary<string, string>();
            var response = new DSCResponse();
            NotificationMasterVM masterNotification = null;
            IEnumerable<NotificationVM> notifications = null;
            var lastViewedDate = DateTime.UtcNow.AddYears(-10);
            var user = await _appCommon.GetUserAsync(userId);
            var isManager = false;
            if (user != null)
            {
                if (user.UserTypeEnum.Equals(PSUserType.ManagementPersonnel.ToString()) || user.UserTypeEnum.Equals(PSUserType.ManagementCompany.ToString()))
                {
                    var roleResponse = await _appCommon.GetUserRoleAsync(user);
                    if (roleResponse.IsSuccess)
                    {
                        var role = roleResponse.ResponseData as AvailableRoleVM;
                        if (role != null)
                        {
                            isManager = role.HasManagementRights;
                        }
                    }
                }
                notifications = await _notificationRepo.GetQueryAsync<NotificationVM>("GetNotifications", new Dictionary<string, object>() {
                        {"recordCount", DataUtil.DefaultNumberOfRows },
                        {"propertyId",propertyId },
                        {"UserId",userId },
                        { "UserType",user.UserTypeEnum },
                        { "IsManager",isManager }
                     });
                var track = await GetNotificationTracksAsync(userId, propertyId);
                if (track != null)
                {
                    lastViewedDate = track.ModifiedDateUtc;
                }
                if (isMainPageView)
                {
                    await SaveNotificationTracksAsync(track, userId, propertyId);
                }
                if (notifications.Any())
                {
                    masterNotification = new NotificationMasterVM()
                    {
                        LastViewDateUTC = lastViewedDate,
                        NonViewedCount = notifications.Count(x => x.AddedDateUtc > lastViewedDate),
                        NotificationVMS = notifications
                    };
                }
            }
            response.ResponseData = masterNotification;
            return response;
        }
public async Task < DSCResponse > GetNotificationsAsync ( Guid userId , Guid propertyId , bool isMainPageView = false ) { var msg = new Dictionary < string , string > ( ) ; var response = new DSCResponse ( ) ; NotificationMasterVM masterNotification = null ; IEnumerable < NotificationVM > notifications = null ; var lastViewedDate = DateTime . UtcNow . AddYears ( - 10 ) ; var user = await _appCommon . GetUserAsync ( userId ) ; var isManager = false ; if ( user != null ) { if ( user . UserTypeEnum . Equals ( PSUserType . ManagementPersonnel . ToString ( ) ) || user . UserTypeEnum . Equals ( PSUserType . ManagementCompany . ToString ( ) ) ) { var roleResponse = await _appCommon . GetUserRoleAsync ( user ) ; if ( roleResponse . IsSuccess ) { var role = roleResponse . ResponseData as AvailableRoleVM ; if ( role != null ) { isManager = role . HasManagementRights ; } } } notifications = await _notificationRepo . GetQueryAsync < NotificationVM > ( " " , new Dictionary < string , object > ( ) { { " " , DataUtil . DefaultNumberOfRows } , { " " , propertyId } , { " " , userId } , { " " , user . UserTypeEnum } , { " " , isManager } } ) ; var track = await GetNotificationTracksAsync ( userId , propertyId ) ; if ( track != null ) { lastViewedDate = track . ModifiedDateUtc ; } if ( isMainPageView ) { await SaveNotificationTracksAsync ( track , userId , propertyId ) ; } if ( notifications . Any ( ) ) { masterNotification = new NotificationMasterVM ( ) { LastViewDateUTC = lastViewedDate , NonViewedCount = notifications . Count ( x => x . AddedDateUtc > lastViewedDate ) , NotificationVMS = notifications } ; } } response . ResponseData = masterNotification ; return response ; }
get notifications as an asynchronous operation.
get notifications as an asynchronous operation .
None
userId
Guid
The user identifier.
The user identifier .
propertyId
Guid
The property identifier.
The property identifier .
isMainPageView
bool
if set to true
if set to true