/// <summary> /// Updates the payment information. /// </summary> /// <param name="paymentInformation">The payment information.</param> /// <param name="auditLogBO">The audit log bo.</param> /// <returns></returns> public async Task <int> UpdatePaymentInformation(PaymentInformationBO paymentInformation, AuditLogBO auditLogBO) { var rows = 0; var statusCode = PaymentUpdate.IsNotUpdated; if (paymentInformation != null) { var member = await _unitOfWork.GetRepository <Member>().GetFirstOrDefaultAsync(a => a, b => b.UserId == paymentInformation.UserId); var memberPayInfoToUpdate = await _unitOfWork.GetRepository <MemberSubscription>().GetPagedListAsync(a => a, predicate: b => b.MemberId == member.MemberId, pageIndex: BrokerConstants.PAGE_INDEX, pageSize: BrokerConstants.PAGE_SIZE); var response = await UpdatePaymentDetailsToAdmin123(paymentInformation, member.Admin123Id, member.MemberId, member.MemberDetailId); //Updating payment information Admin123 if (response.Trim().ToLower().Equals("ok")) { foreach (var memberPaymentInfo in memberPayInfoToUpdate.Items) { if (paymentInformation.IsCardUpdate) { memberPaymentInfo.RoutingNumber = string.Empty; memberPaymentInfo.CardOrAccountNumber = paymentInformation.CreditCardNumber; memberPaymentInfo.PaymentType = (int)PaymentType.CC; memberPaymentInfo.ModifiedBy = paymentInformation.UserId; memberPaymentInfo.ModifiedOn = DateTime.Now; } else { memberPaymentInfo.CardOrAccountNumber = paymentInformation.BankAccountNumber; memberPaymentInfo.PaymentType = (int)PaymentType.ACH; memberPaymentInfo.RoutingNumber = paymentInformation.BankRoutingNumber; memberPaymentInfo.ModifiedBy = paymentInformation.UserId; memberPaymentInfo.ModifiedOn = DateTime.Now; } _unitOfWork.GetRepository <MemberSubscription>().Update(memberPaymentInfo); } rows = _unitOfWork.SaveChanges(); if (rows > 0) { statusCode = PaymentUpdate.IsUpdated; } } //Log audit for update action on Payment Information await AuditMapper.AuditLogging(auditLogBO, paymentInformation.MemberId, AuditAction.Update, paymentInformation); } return((int)statusCode); }
/// <summary> /// Marks the message as read. /// </summary> /// <param name="memberMessageId">The member message identifier.</param> /// <param name="auditLogBO">The audit log bo.</param> /// <returns></returns> public async Task <int> MarkMessageAsRead(long memberMessageId, AuditLogBO auditLogBO) { var rows = 0; var memberMessageRepo = _unitOfWork.GetRepository <Messages>(); var memberMessage = await memberMessageRepo.FindAsync(memberMessageId); var existingMemberMessage = new Messages(); existingMemberMessage = existingMemberMessage.Clone(memberMessage); if (memberMessage != null) { memberMessage.IsRead = true; rows = _unitOfWork.SaveChanges(); } //Log audit for update action on MemberMessage await AuditMapper.AuditLogging(auditLogBO, memberMessageId, AuditAction.Update, null); return(rows); }
/// <summary> /// Deletes the message. /// </summary> /// <param name="memberMessageId">The member message identifier.</param> /// <param name="auditLogBO">The audit log bo.</param> /// <returns></returns> public async Task <int> DeleteMessage(List <long> memberMessageId, AuditLogBO auditLogBO) { var rows = 0; var memberMessage = await _unitOfWork.GetRepository <Messages>().GetPagedListAsync(predicate: msg => msg.PortalId == (int)Portals.MemberPortal && memberMessageId.Contains(msg.MessageId), pageIndex: 0, pageSize: int.MaxValue); var existingMemberMessages = new List <Messages>(); existingMemberMessages = existingMemberMessages.Clone(memberMessage.Items.ToList()); if (memberMessage != null && memberMessage.Items.Any()) { _unitOfWork.GetRepository <Messages>().Delete(memberMessage.Items); rows = await _unitOfWork.SaveChangesAsync(); } //Log audit for update action on MemberMessage await AuditMapper.AuditLogging(auditLogBO, memberMessageId[0], AuditAction.Delete, null); return(rows); }
/// <summary> /// Updates the security questions by user identifier. /// </summary> /// <param name="updatedSecurityQuestions">The updated security questions.</param> /// <param name="auditLogBO">The audit log bo.</param> /// <returns></returns> public async Task <bool> UpdateSecurityQuestionsByUserId(List <SecurityQuestionAnswersBO> updatedSecurityQuestions, AuditLogBO auditLogBO) { var rows = 0; var isUpdated = false; if (updatedSecurityQuestions != null) { var securityQA = await _unitOfWork.GetRepository <UserSecurityQuestionAnswers>().GetPagedListAsync( a => a, predicate: b => b.UserId == updatedSecurityQuestions[0].UserId, pageIndex: 0, pageSize: 3); _unitOfWork.GetRepository <UserSecurityQuestionAnswers>().Delete(securityQA.Items); var userSecurityQA = updatedSecurityQuestions.Select(qa => new UserSecurityQuestionAnswers { UserId = qa.UserId, SecurityQuestionId = qa.SecurityQuestionId, Answer = EncryptionHelper.HashCode(qa.Answer), CreatedOn = DateTime.Now, CreatedBy = qa.UserId, ModifiedOn = DateTime.Now, ModifiedBy = qa.UserId }); await _unitOfWork.GetRepository <UserSecurityQuestionAnswers>().InsertAsync(userSecurityQA); rows = _unitOfWork.SaveChanges(); if (rows > 0) { isUpdated = true; } } await AuditMapper.AuditLogging(auditLogBO, updatedSecurityQuestions[0].UserId, AuditAction.Update, updatedSecurityQuestions); return(isUpdated); }
/// <summary> /// Updates the member demographics. /// </summary> /// <param name="memberDemographics">The member demographics.</param> /// <param name="auditLogBO">The audit log bo.</param> /// <returns></returns> public async Task <int> UpdateMemberDemographics(MemberDemographicsBO memberDemographics, AuditLogBO auditLogBO) { var isUpdateCount = 0; var admin123Response = string.Empty; if (memberDemographics != null) { //Update Member PhoneNumber, Email & Address in Admin123 admin123Response = await InvokeAdmin123Async(memberDemographics); if (admin123Response.Equals(HttpStatusCode.OK.ToString())) { // Update Member PhoneNumber, Email & Address in MemberPortal Database if (memberDemographics.MemberAddress != null) { var memberAddressRepo = _unitOfWork.GetRepository <MemberAddress>(); foreach (var addrToUpdate in memberDemographics.MemberAddress) { if (addrToUpdate.Id != 0) { var repoMemberAddress = memberAddressRepo.GetFirstOrDefault(a => a, b => b.MemberId == addrToUpdate.Id); var existingMemberAddress = new MemberAddress(); existingMemberAddress = existingMemberAddress.Clone(repoMemberAddress); if (repoMemberAddress != null) { repoMemberAddress.AddressLine1 = addrToUpdate.AddressLine1; repoMemberAddress.AddressLine2 = addrToUpdate.AddressLine2; repoMemberAddress.City = addrToUpdate.City; repoMemberAddress.StateCode = addrToUpdate.StateCode; repoMemberAddress.ZipCode = addrToUpdate.ZipCode; } var isInvalidState = await ValidateState(addrToUpdate.StateCode); if (!isInvalidState) { _unitOfWork.GetRepository <MemberAddress>().Update(repoMemberAddress); isUpdateCount += _unitOfWork.SaveChanges(); } else { return((int)Utilities.Enumerations.ValidateState.StateInvalid); } //Log audit for update action on BrokerAddress await AuditMapper.AuditLogging(auditLogBO, memberDemographics.MemberID, AuditAction.Update, repoMemberAddress, existingMemberAddress); } } } if (memberDemographics.MemberDetails != null && Convert.ToInt64(memberDemographics.MemberDetails.MemberId) != 0) { var memberDetailsRepo = _unitOfWork.GetRepository <MemberDetail>(); var memberContact = await memberDetailsRepo.GetFirstOrDefaultAsync(a => a, b => b.MemberDetailId == memberDemographics.MemberDetailId); var existingMemberDetail = new MemberDetail(); existingMemberDetail = existingMemberDetail.Clone(memberContact); memberContact.PhoneNumber = memberDemographics.MemberDetails.PhoneNumber; memberContact.EmailId = memberDemographics.MemberDetails.Email; _unitOfWork.GetRepository <MemberDetail>().Update(memberContact); isUpdateCount += _unitOfWork.SaveChanges(); //Log audit for update action await AuditMapper.AuditLogging(auditLogBO, memberDemographics.MemberDetailId, AuditAction.Update, memberContact, existingMemberDetail); } } } if (isUpdateCount > 1) { return((int)EditInformationStatus.Success); } else { return((int)EditInformationStatus.Fail); } }
/// <summary> /// Updates the digital document identifier. /// </summary> /// <param name="digitalDoc">The digital document.</param> /// <param name="auditLogBO">The audit log bo.</param> /// <returns></returns> /// <exception cref="Exception">Unexpected Case</exception> public async Task <bool> UpdateDigitalDocumentId(DigitalDocumentBO digitalDoc, AuditLogBO auditLogBO) { var response = false; if (digitalDoc != null) { switch (digitalDoc.DocumentType.ToLower()) { case MemberConstants.ClaimsEOB: //Updating EOB document id in Claims table var claimsRepository = _unitOfWork.GetRepository <Claims>(); var claim = await claimsRepository.GetFirstOrDefaultAsync(predicate : c => Convert.ToInt64(c.ClaimsNumber) == digitalDoc.Identifier); if (claim != null) { claim.DocumentId = digitalDoc.DocumentId; claimsRepository.Update(claim); } break; case MemberConstants.ProductGuideBook: //Updating product guidebook id in product table var productRepository = _unitOfWork.GetRepository <Product>(); var product = await productRepository.GetFirstOrDefaultAsync(predicate : prd => prd.ProductCode == digitalDoc.Identifier); if (product != null) { product.DocumentId = digitalDoc.DocumentId; productRepository.Update(product); } break; case MemberConstants.DigitalIDCard: //Updating digital id card id in member/member dependent table if (digitalDoc.MemberType.ToLower().Equals(MemberConstants.Self)) { var memberRepository = _unitOfWork.GetRepository <Member>(); var member = await memberRepository.GetFirstOrDefaultAsync(predicate : m => m.UserId == digitalDoc.Identifier); if (member != null) { member.DigitalIdcardId = digitalDoc.DocumentId; memberRepository.Update(member); } } else if (digitalDoc.MemberType.ToLower().Equals(MemberConstants.Dependent)) { var memberDependentRepository = _unitOfWork.GetRepository <MemberDependent>(); var memberDependent = await memberDependentRepository.GetFirstOrDefaultAsync(predicate : m => m.MemberDetailId == digitalDoc.Identifier); if (memberDependent != null) { memberDependent.DigitalIdcardId = digitalDoc.DocumentId; memberDependentRepository.Update(memberDependent); } } break; case MemberConstants.AvatarImage: //Updating avatar image id in member details table var memberDetailRepository = _unitOfWork.GetRepository <MemberDetail>(); if (digitalDoc.MemberType.ToLower().Equals(MemberConstants.Self)) { var memberRepository = _unitOfWork.GetRepository <Member>(); var member = await memberRepository.GetFirstOrDefaultAsync(predicate : m => m.UserId == digitalDoc.Identifier); if (member != null) { var memberDetail = await memberDetailRepository.GetFirstOrDefaultAsync(predicate : md => md.MemberDetailId == member.MemberDetailId); if (memberDetail != null) { memberDetail.AvatarImageId = digitalDoc.DocumentId; memberDetailRepository.Update(memberDetail); } } } else if (digitalDoc.MemberType.ToLower().Equals(MemberConstants.Dependent)) { var memberDetail = await memberDetailRepository.GetFirstOrDefaultAsync(predicate : md => md.MemberDetailId == digitalDoc.Identifier); if (memberDetail != null) { memberDetail.AvatarImageId = digitalDoc.DocumentId; memberDetailRepository.Update(memberDetail); } } break; default: break; } var rowsAffected = await _unitOfWork.SaveChangesAsync(); if (rowsAffected > 0) { response = true; } //Log audit await AuditMapper.AuditLogging(auditLogBO, null, AuditAction.Update, digitalDoc); } return(response); }
/// <summary> /// To save member feedback to db /// </summary> /// <param name="memberFeedbackBO"></param> /// <param name="auditLogBO"></param> /// <returns></returns> public async Task <bool> SaveMemberFeedback(MemberFeedbackBO memberFeedbackBO, AuditLogBO auditLogBO) { var returnValue = false; if (memberFeedbackBO != null) { var member = await _unitOfWork.GetRepository <Member>().GetFirstOrDefaultAsync(i => i, u => u.UserId == memberFeedbackBO.UserId); if (member != null) { var memberDetails = await _unitOfWork.GetRepository <MemberDetail>().GetFirstOrDefaultAsync(i => i, m => m.MemberDetailId == member.MemberDetailId); memberFeedbackBO.MemberExternalId = member.ExternalId; var memberFeedbackInfo = MemberMapper.Map(memberFeedbackBO); _unitOfWork.GetRepository <MemberFeedback>().Insert(memberFeedbackInfo); var recordsInserted = await _unitOfWork.SaveChangesAsync(); if (recordsInserted > 0) { returnValue = true; var mailIdFrom = ""; var mailTo = ""; var body = ""; var subject = ""; if (memberFeedbackBO.SourceId == (int)MemberFeedbackType.ShareStory) { mailTo = memberFeedbackBO.Email; var notificaton = await _unitOfWork.GetRepository <Notification>().GetFirstOrDefaultAsync(predicate: n => n.Type == (int)EmailType.MemberStory); if (notificaton != null) { subject = notificaton.Subject; body = notificaton.Content.Replace("{firstname}", memberDetails.FirstName).Replace("{lastname}", memberDetails.LastName); mailIdFrom = notificaton.From; } notificaton = await _unitOfWork.GetRepository <Notification>().GetFirstOrDefaultAsync(predicate: n => n.Type == (int)EmailType.MemberStoryTestimonial); if (notificaton != null) { var marketingMailSubject = notificaton.Subject; var marketingMailBody = notificaton.Content.Replace("{firstname}", memberDetails.FirstName). Replace("{lastname}", memberDetails.LastName).Replace("{email}", memberFeedbackBO.Email). Replace("{message}", memberFeedbackBO.Message); mailIdFrom = notificaton.From; var email = MemberMapper.Map(_appSettings.Value.AlieraMarketingEmail, marketingMailBody, marketingMailSubject, _appSettings, mailIdFrom); await _emailService.SendEmailAsync(email); } } else if (memberFeedbackBO.SourceId == (int)MemberFeedbackType.ShareContactInfo) { mailTo = memberFeedbackBO.InquiryTypeEmail; var notificaton = await _unitOfWork.GetRepository <Notification>().GetFirstOrDefaultAsync(predicate: n => n.Type == (int)EmailType.MemberContactSubmission); if (notificaton != null) { subject = notificaton.Subject; body = notificaton.Content.Replace("{firstname}", memberDetails.FirstName). Replace("{lastname}", memberDetails.LastName).Replace("{email}", memberFeedbackBO.Email). Replace("{message}", memberFeedbackBO.Message).Replace("{phonenumber}", memberFeedbackBO.PhoneNumber) .Replace("{Inquirytype}", memberFeedbackBO.InquiryType); mailIdFrom = notificaton.From; } } var emailDetails = MemberMapper.Map(mailTo, body, subject, _appSettings, mailIdFrom); await _emailService.SendEmailAsync(emailDetails); } } } await AuditMapper.AuditLogging(auditLogBO, memberFeedbackBO.UserId, AuditAction.Insert, memberFeedbackBO); return(returnValue); }
/// <summary> /// Registers the member. /// </summary> /// <param name="memberRegistration">The member registration.</param> /// <param name="auditLogBO">The audit log bo.</param> /// <returns></returns> public async Task <int> RegisterMember(MemberRegistrationBO memberRegistration, AuditLogBO auditLogBO) { bool isSuccessful; var externalId = memberRegistration.ExternalId; var statusCode = MemberRegistrationVerification.InvalidMemberId; var isRegistrationSuccessful = 0; if (!string.IsNullOrEmpty(externalId)) { statusCode = await VerifyMemberDetails(memberRegistration, externalId, statusCode); if (statusCode == MemberRegistrationVerification.Verified) { var user = MemberMapper.Map(memberRegistration); using (var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { try { //_unitOfWork.GetRepository<Users>().Insert(user); //_unitOfWork.DbContext.Database.ExecuteSqlCommand("SET IDENTITY_INSERT dbo.Users ON"); //isRegistrationSuccessful += _unitOfWork.SaveChanges(); //_unitOfWork.DbContext.Database.ExecuteSqlCommand("SET IDENTITY_INSERT dbo.Users OFF"); var newUserIdSecurityQA = memberRegistration.SecurityQuestionAnswer.Select(item => new UserSecurityQuestionAnswers { UserId = user.UserId, SecurityQuestionId = item.SecurityQuestionId, Answer = EncryptionHelper.HashCode(item.Answer), CreatedBy = item.CreatedBy, CreatedOn = DateTime.UtcNow, ModifiedBy = item.ModifiedBy, ModifiedOn = memberRegistration.ModifiedOn }); _unitOfWork.GetRepository <UserSecurityQuestionAnswers>().Insert(newUserIdSecurityQA); isRegistrationSuccessful += _unitOfWork.SaveChanges(); } catch (Exception ex) { scope.Dispose(); throw; } scope.Complete(); } isSuccessful = isRegistrationSuccessful > 0; if ((isSuccessful && memberRegistration.UpdateToAdmin123) || memberRegistration.PhoneNumberNotFound || memberRegistration.EmailNotFound) { await this.UpateMemberEmailAndPhoneNumber(memberRegistration); await this.UpateEmailAndPhoneNumberToAdmin123(memberRegistration); } await AuditMapper.AuditLogging(auditLogBO, null, AuditAction.Update, memberRegistration); } else { isSuccessful = false; } if (isSuccessful) { await SendRegistrationConformationMail(memberRegistration); } } return((int)statusCode); }