DocSas/PropertyService.Domain/ModelView/ServiceRequests/ServiceRequestProvider.cs
/// <summary>
/// save service request status as an asynchronous operation.
/// </summary>
/// <param name="serviceRequestStatus">The service request status.</param>
/// <returns>Task&lt;DSCResponse&gt;.</returns>
save service request status as an asynchronous operation.
save service request status as an asynchronous operation .
public async Task<DSCResponse> SaveServiceRequestStatusAsync(ServiceRequestStatusVM serviceRequestStatus)
        {
            var msg = new Dictionary<string, string>();
            var response = new DSCResponse();
            var isSuccess = false;
            var isAllow = false;
            var serviceRequest = await _serviceRequestRepo.GetSingleAsync(x => x.Id == serviceRequestStatus.Id);
            if (serviceRequest != null)
            {
                if (serviceRequest.UserId == serviceRequestStatus.UserId)
                {
                    isAllow = true;
                }
                else
                {
                    var management = await _appCommon.GetManagementUserAsync(serviceRequestStatus.UserId);
                    isAllow = management != null;
                }
            }
            if (isAllow)
            {
                serviceRequest.RequestStatusKey = serviceRequestStatus.StatusKey;
                isSuccess = await _serviceRequestRepo.ModifyAsync(serviceRequest);
                NotificationVM notification = new NotificationVM()
                {
                    UserId = serviceRequest.UserId,
                    PropertyInformationId = serviceRequest.PropertyInformationId,
                    NotificationResourceKey = NotificationResourceKeys.NotifyServiceStatusChanged + serviceRequestStatus.StatusKey,
                    NotificationTypeEnum = PSNotificationType.ServiceRequest.ToString(),
                    NotificationShowFor = serviceRequest.UserId == serviceRequestStatus.UserId ? PSNotificationShowFor.Property.ToString() : PSNotificationShowFor.User.ToString(),
                    NotificationTypeId = serviceRequest.Id,
                    NotifeeUserId = serviceRequest.UserId == serviceRequestStatus.UserId ? Guid.Empty : serviceRequest.UserId,
                    NotificationAdditionalInfo = string.Concat(serviceRequest.TenantUnitAddress, " - ", serviceRequest.Title)
                };
                await _appCommon.AddNotification(notification);
            }
            response.ResponseData = isSuccess;
            response.ErrorMessage = msg;
            return response;
        }
public async Task < DSCResponse > SaveServiceRequestStatusAsync ( ServiceRequestStatusVM serviceRequestStatus ) { var msg = new Dictionary < string , string > ( ) ; var response = new DSCResponse ( ) ; var isSuccess = false ; var isAllow = false ; var serviceRequest = await _serviceRequestRepo . GetSingleAsync ( x => x . Id == serviceRequestStatus . Id ) ; if ( serviceRequest != null ) { if ( serviceRequest . UserId == serviceRequestStatus . UserId ) { isAllow = true ; } else { var management = await _appCommon . GetManagementUserAsync ( serviceRequestStatus . UserId ) ; isAllow = management != null ; } } if ( isAllow ) { serviceRequest . RequestStatusKey = serviceRequestStatus . StatusKey ; isSuccess = await _serviceRequestRepo . ModifyAsync ( serviceRequest ) ; NotificationVM notification = new NotificationVM ( ) { UserId = serviceRequest . UserId , PropertyInformationId = serviceRequest . PropertyInformationId , NotificationResourceKey = NotificationResourceKeys . NotifyServiceStatusChanged + serviceRequestStatus . StatusKey , NotificationTypeEnum = PSNotificationType . ServiceRequest . ToString ( ) , NotificationShowFor = serviceRequest . UserId == serviceRequestStatus . UserId ? PSNotificationShowFor . Property . ToString ( ) : PSNotificationShowFor . User . ToString ( ) , NotificationTypeId = serviceRequest . Id , NotifeeUserId = serviceRequest . UserId == serviceRequestStatus . UserId ? Guid . Empty : serviceRequest . UserId , NotificationAdditionalInfo = string . Concat ( serviceRequest . TenantUnitAddress , " " , serviceRequest . Title ) } ; await _appCommon . AddNotification ( notification ) ; } response . ResponseData = isSuccess ; response . ErrorMessage = msg ; return response ; }
save service request status as an asynchronous operation.
save service request status as an asynchronous operation .
None
serviceRequestStatus
ServiceRequestStatusVM
The service request status.
The service request status .