DocSas/PropertyService.Domain/ModelView/Users/UserProvider.cs
/// <summary>
/// retrieve account as an asynchronous operation.
/// </summary>
/// <param name="userVM">The user vm.</param>
/// <returns>Task&lt;DSCResponse&gt;.</returns>
retrieve account as an asynchronous operation.
retrieve account as an asynchronous operation .
public async Task<DSCResponse> RetrieveAccountAsync(UserVM userVM)
        {
            var msg = new Dictionary<string, string>();
            var response = new DSCResponse();
            var entity = await _userRepo.GetSingleAsync(x => x.Email.Equals(userVM.Email, StringComparison.OrdinalIgnoreCase));
            if (entity == null)
            {
                msg.Add("AccountNotFound", "Account not found");
            }
            else if (entity.IsDemoAccount)
            {
                msg.Add("DemoFunctionalityLimited", "Demo item: Functionality not allowed.");
            }
            else if (!entity.IsActive.HasValue)
            {
                msg.Add("AccountNotConfirmed", "Confirm your account");
            }
            else if (entity.IsLockedOut)
            {
                msg.Add("AccountLockedOut", "Account Locked");
            }
            else if (entity.IsBanned)
            {
                msg.Add("AccountBanned", "User Banned");
            }
            else if(entity.IsActive.Value)
            {
                if (entity.SecurityQuestionId.HasValue)
                {
                    var securityQuestions = await _securityQuestionRepo.GetSingleAsync(x => x.Id == entity.SecurityQuestionId);
                    if (securityQuestions != null)
                    {
                        userVM.SecurityQuestion = securityQuestions.Question;
                        userVM.Id = entity.Id;
                        userVM.FirstName = entity.FirstName;
                    }                  
                }
                else
                {
                    var genResponse = await GenerateAndSendPasswordResetAsync(entity);
                    if (!genResponse.IsSuccess)
                    {
                        msg.Add("Failed", "Failed");
                    }
                }
            }
            else
            {
                msg.Add("AccountNotFound", "Account not found");
            }
            response.ResponseData = userVM;
            response.ErrorMessage = msg;
            return response;
        }
public async Task < DSCResponse > RetrieveAccountAsync ( UserVM userVM ) { var msg = new Dictionary < string , string > ( ) ; var response = new DSCResponse ( ) ; var entity = await _userRepo . GetSingleAsync ( x => x . Email . Equals ( userVM . Email , StringComparison . OrdinalIgnoreCase ) ) ; if ( entity == null ) { msg . Add ( " " , " " ) ; } else if ( entity . IsDemoAccount ) { msg . Add ( " " , " " ) ; } else if ( ! entity . IsActive . HasValue ) { msg . Add ( " " , " " ) ; } else if ( entity . IsLockedOut ) { msg . Add ( " " , " " ) ; } else if ( entity . IsBanned ) { msg . Add ( " " , " " ) ; } else if ( entity . IsActive . Value ) { if ( entity . SecurityQuestionId . HasValue ) { var securityQuestions = await _securityQuestionRepo . GetSingleAsync ( x => x . Id == entity . SecurityQuestionId ) ; if ( securityQuestions != null ) { userVM . SecurityQuestion = securityQuestions . Question ; userVM . Id = entity . Id ; userVM . FirstName = entity . FirstName ; } } else { var genResponse = await GenerateAndSendPasswordResetAsync ( entity ) ; if ( ! genResponse . IsSuccess ) { msg . Add ( " " , " " ) ; } } } else { msg . Add ( " " , " " ) ; } response . ResponseData = userVM ; response . ErrorMessage = msg ; return response ; }
retrieve account as an asynchronous operation.
retrieve account as an asynchronous operation .
None
userVM
UserVM
The user vm.
The user vm .