Adding
This commit is contained in:
+28
@@ -0,0 +1,28 @@
|
||||
using LCU.Library.Internal.IncentiveApiModels.Entities;
|
||||
using LCU.API.Internal.Operations.IncentiveApi.Models.ExternalActivities;
|
||||
|
||||
namespace LCU.API.Internal.Operations.IncentiveApi.Services.ExternalActivity;
|
||||
|
||||
public class ExternalActivityService : IExternalActivityService
|
||||
{
|
||||
private readonly IEnumerable<IExternalActivityStrategy> _strategies;
|
||||
|
||||
public ExternalActivityService(IEnumerable<IExternalActivityStrategy> strategies)
|
||||
{
|
||||
_strategies = strategies;
|
||||
}
|
||||
|
||||
public async Task<Activity> TryMapExternalActivity(IExternalActivity externalActivity)
|
||||
{
|
||||
var strategy = _strategies.FirstOrDefault(x => x.CanMapActivity(externalActivity));
|
||||
|
||||
if (strategy != null)
|
||||
{
|
||||
return await strategy.MapToActivityManagerActivity(externalActivity);
|
||||
}
|
||||
|
||||
Log.Error($"Failed to find strategy for External Activity for product {externalActivity.GetProductType()}. Falling back to basic method. Some data may be missing.");
|
||||
var activity = externalActivity.MapToActivity();
|
||||
return activity;
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
using LCU.Library.Internal.IncentiveApiModels.Entities;
|
||||
using LCU.API.Internal.Operations.IncentiveApi.Models.ExternalActivities;
|
||||
|
||||
namespace LCU.API.Internal.Operations.IncentiveApi.Services.ExternalActivity;
|
||||
|
||||
public interface IExternalActivityService
|
||||
{
|
||||
public Task<Activity> TryMapExternalActivity(IExternalActivity externalActivity);
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
using LCU.Library.Internal.IncentiveApiModels.Entities;
|
||||
using LCU.API.Internal.Operations.IncentiveApi.Models.ExternalActivities;
|
||||
|
||||
namespace LCU.API.Internal.Operations.IncentiveApi.Services.ExternalActivity;
|
||||
|
||||
public interface IExternalActivityStrategy
|
||||
{
|
||||
public bool CanMapActivity(IExternalActivity activity);
|
||||
public Task<Activity> MapToActivityManagerActivity(IExternalActivity activity);
|
||||
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
using LCU.API.Internal.Operations.IncentiveApi.Models.DataTransfer;
|
||||
using LCU.API.Internal.Operations.IncentiveApi.Models.ExternalActivities;
|
||||
using LCU.API.Internal.Operations.IncentiveApiLib.Services;
|
||||
using LCU.API.Internal.Operations.IncentiveApiLib.Repositories;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Entities;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Enums;
|
||||
|
||||
namespace LCU.API.Internal.Operations.IncentiveApi.Services.ExternalActivity;
|
||||
|
||||
public class NewIncentiveManagerActivityStrategy : IExternalActivityStrategy
|
||||
{
|
||||
private readonly IUserService _userService;
|
||||
private readonly IDepartmentRepository _departmentRepository;
|
||||
|
||||
public NewIncentiveManagerActivityStrategy(IUserService userService, IDepartmentRepository departmentRepository)
|
||||
{
|
||||
_userService = userService;
|
||||
_departmentRepository = departmentRepository;
|
||||
}
|
||||
|
||||
public bool CanMapActivity(IExternalActivity activity)
|
||||
{
|
||||
return activity.GetActivityType() == ActivityType.Referral &&
|
||||
(activity.GetProductType() == Product.ATMCard ||
|
||||
activity.GetProductType() == Product.CheckCard ||
|
||||
activity.GetProductType() == Product.NewChecking ||
|
||||
activity.GetProductType() == Product.Mortgage ||
|
||||
activity.GetProductType() == Product.DirectDeposit ||
|
||||
activity.GetProductType() == Product.CreditCardBalanceTransfer ||
|
||||
activity.GetProductType() == Product.LIC ||
|
||||
activity.GetProductType() == Product.FirstMortgageReferral ||
|
||||
activity.GetProductType() == Product.eStatement);
|
||||
}
|
||||
|
||||
public async Task<Activity> MapToActivityManagerActivity(IExternalActivity activity)
|
||||
{
|
||||
AppUser appUser = null;
|
||||
Department department = null;
|
||||
try
|
||||
{
|
||||
if (activity is NewActivityManagerReferral newActivityManagerReferral)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(newActivityManagerReferral.EmployeeEmail))
|
||||
{
|
||||
appUser = await _userService.TryFindSingleUserByName(new UserNameSearchRequest()
|
||||
{
|
||||
FirstName = newActivityManagerReferral.OriginatorFirstName,
|
||||
MiddleInit = newActivityManagerReferral.OriginatorMiddleInitial,
|
||||
LastName = newActivityManagerReferral.OriginatorLastName
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
appUser = await _userService.GetUserByAdEmailAsync(newActivityManagerReferral.EmployeeEmail);
|
||||
}
|
||||
|
||||
department =
|
||||
await _departmentRepository.FindDepartmentByBranchName(newActivityManagerReferral
|
||||
.OriginatingBranchName);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex,
|
||||
$"Failed to get data for NewIncentiveManagerActivity with sourceId: {activity.MapToActivity().SourceId}. Falling back to basic mapping.");
|
||||
}
|
||||
|
||||
var mappedActivity = activity.MapToActivity();
|
||||
mappedActivity.AppUserId = appUser?.Id ?? Guid.Empty;
|
||||
mappedActivity.EmployeeId = appUser?.EmployeeId;
|
||||
mappedActivity.DepartmentId = department?.Id ?? -1;
|
||||
return mappedActivity;
|
||||
}
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
using LCU.API.Internal.Operations.IncentiveApi.Models.DataTransfer;
|
||||
using LCU.API.Internal.Operations.IncentiveApi.Models.ExternalActivities;
|
||||
using LCU.API.Internal.Operations.IncentiveApiLib.Services;
|
||||
using LCU.API.Internal.Operations.IncentiveApiLib.Repositories;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Entities;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Enums;
|
||||
|
||||
namespace LCU.API.Internal.Operations.IncentiveApi.Services.ExternalActivity;
|
||||
|
||||
public class NewAtmCheckCardActivityStrategy : IExternalActivityStrategy
|
||||
{
|
||||
private readonly IUserService _userService;
|
||||
private readonly IDepartmentRepository _departmentRepository;
|
||||
|
||||
public NewAtmCheckCardActivityStrategy(IUserService userService, IDepartmentRepository departmentRepository)
|
||||
{
|
||||
_userService = userService;
|
||||
_departmentRepository = departmentRepository;
|
||||
}
|
||||
|
||||
public bool CanMapActivity(IExternalActivity activity)
|
||||
{
|
||||
return activity.GetActivityType() == ActivityType.Other && (activity.GetProductType() == Product.ATMCard ||
|
||||
activity.GetProductType() == Product.CheckCard);
|
||||
}
|
||||
|
||||
public async Task<Activity> MapToActivityManagerActivity(IExternalActivity activity)
|
||||
{
|
||||
AppUser appUser = null;
|
||||
Department department = null;
|
||||
try
|
||||
{
|
||||
if (activity is NewAtmCheckCardActivity atmCheckCardActivity)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(atmCheckCardActivity.EmployeeEmail))
|
||||
{
|
||||
appUser = await _userService.TryFindSingleUserByName(new UserNameSearchRequest()
|
||||
{
|
||||
FirstName = atmCheckCardActivity.AssociateFirst,
|
||||
MiddleInit = atmCheckCardActivity.AssociateMiddleInit,
|
||||
LastName = atmCheckCardActivity.AssociateLast
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
appUser = await _userService.GetUserByAdEmailAsync(atmCheckCardActivity.EmployeeEmail);
|
||||
}
|
||||
}
|
||||
|
||||
if (appUser == null)
|
||||
{
|
||||
return activity.MapToActivity();
|
||||
}
|
||||
|
||||
department = await _departmentRepository.FindUserHomeDepartment(appUser);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex,
|
||||
$"Failed to get data for NewAtmCheckCardActivity with sourceId: {activity.MapToActivity().SourceId}. Falling back to basic mapping.");
|
||||
}
|
||||
|
||||
var mappedActivity = activity.MapToActivity();
|
||||
mappedActivity.AppUserId = appUser?.Id ?? Guid.Empty;
|
||||
mappedActivity.EmployeeId = appUser?.EmployeeId;
|
||||
mappedActivity.DepartmentId = department?.Id ?? -1;
|
||||
return mappedActivity;
|
||||
}
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
using LCU.API.Internal.Operations.IncentiveApi.Models.DataTransfer;
|
||||
using LCU.API.Internal.Operations.IncentiveApi.Models.ExternalActivities;
|
||||
using LCU.API.Internal.Operations.IncentiveApiLib.Services;
|
||||
using LCU.API.Internal.Operations.IncentiveApiLib.Repositories;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Entities;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Enums;
|
||||
|
||||
namespace LCU.API.Internal.Operations.IncentiveApi.Services.ExternalActivity;
|
||||
|
||||
public class NewCheckingAccountActivityStrategy : IExternalActivityStrategy
|
||||
{
|
||||
private readonly IUserService _userService;
|
||||
private readonly IDepartmentRepository _departmentRepository;
|
||||
|
||||
public NewCheckingAccountActivityStrategy(IUserService userService, IDepartmentRepository departmentRepository)
|
||||
{
|
||||
_userService = userService;
|
||||
_departmentRepository = departmentRepository;
|
||||
}
|
||||
|
||||
public bool CanMapActivity(IExternalActivity activity)
|
||||
{
|
||||
return activity.GetActivityType() == ActivityType.Sale &&
|
||||
activity.GetProductType() == Product.NewChecking;
|
||||
}
|
||||
|
||||
public async Task<Activity> MapToActivityManagerActivity(IExternalActivity activity)
|
||||
{
|
||||
AppUser appUser = null;
|
||||
Department department = null;
|
||||
try
|
||||
{
|
||||
if (activity is NewCheckingAccountActivity newCheckingActivity)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(newCheckingActivity.EmployeeEmail))
|
||||
{
|
||||
appUser = await _userService.TryFindSingleUserByName(new UserNameSearchRequest()
|
||||
{
|
||||
FirstName = newCheckingActivity.AssociateFirst,
|
||||
LastName = newCheckingActivity.AssociateLast,
|
||||
MiddleInit = newCheckingActivity.AssociateMiddleInit,
|
||||
DnaOrgNbr = newCheckingActivity.BranchOrgNbr.ToString()
|
||||
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
appUser = await _userService.GetUserByAdEmailAsync(newCheckingActivity.EmployeeEmail);
|
||||
}
|
||||
|
||||
if (appUser == null)
|
||||
{
|
||||
return activity.MapToActivity();
|
||||
}
|
||||
|
||||
department = await _departmentRepository.FindUserHomeDepartment(appUser);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex,
|
||||
$"Failed to get data for NewCheckingAccountActivity with sourceId: {activity.GetSourceId()}. Falling back to basic mapping.");
|
||||
}
|
||||
|
||||
var mappedActivity = activity.MapToActivity();
|
||||
mappedActivity.AppUserId = appUser?.Id ?? Guid.Empty;
|
||||
mappedActivity.EmployeeId = appUser?.EmployeeId;
|
||||
mappedActivity.DepartmentId = department?.Id ?? -1;
|
||||
return mappedActivity;
|
||||
}
|
||||
|
||||
}
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
using LCU.API.Internal.Operations.IncentiveApi.Models.DataTransfer;
|
||||
using LCU.API.Internal.Operations.IncentiveApi.Models.ExternalActivities;
|
||||
using LCU.API.Internal.Operations.IncentiveApiLib.Services;
|
||||
using LCU.API.Internal.Operations.IncentiveApiLib.Repositories;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Entities;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Enums;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Requests;
|
||||
|
||||
namespace LCU.API.Internal.Operations.IncentiveApi.Services.ExternalActivity;
|
||||
|
||||
public class NewDebtProtectionEligibleLoanStrategy : IExternalActivityStrategy
|
||||
{
|
||||
private readonly IUserService _userService;
|
||||
private readonly IDepartmentRepository _departmentRepository;
|
||||
|
||||
public NewDebtProtectionEligibleLoanStrategy(IUserService userService, IDepartmentRepository departmentRepository)
|
||||
{
|
||||
_userService = userService;
|
||||
_departmentRepository = departmentRepository;
|
||||
}
|
||||
|
||||
public bool CanMapActivity(IExternalActivity activity)
|
||||
{
|
||||
return activity.GetActivityType() == ActivityType.Sale && activity.GetProductType() == Product.DebtProtectionEligibleLoan;
|
||||
}
|
||||
|
||||
public async Task<Activity> MapToActivityManagerActivity(IExternalActivity activity)
|
||||
{
|
||||
AppUser appUser = null;
|
||||
Department department = null;
|
||||
try
|
||||
{
|
||||
if (activity is NewLoanSaleActivity newDpEligibleLoanSale)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(newDpEligibleLoanSale.EmployeeEmail))
|
||||
{
|
||||
appUser = await _userService.TryFindSingleUserByName(new UserNameSearchRequest()
|
||||
{
|
||||
FirstName = newDpEligibleLoanSale.AssociateFirst,
|
||||
LastName = newDpEligibleLoanSale.AssociateLast,
|
||||
MiddleInit = newDpEligibleLoanSale.AssociateMiddleInit,
|
||||
DnaOrgNbr = newDpEligibleLoanSale.BranchOrgNbr.ToString()
|
||||
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
appUser = await _userService.GetUserByAdEmailAsync(newDpEligibleLoanSale.EmployeeEmail);
|
||||
}
|
||||
|
||||
if (appUser == null)
|
||||
{
|
||||
return activity.MapToActivity();
|
||||
}
|
||||
|
||||
department = await _departmentRepository.FindUserHomeDepartment(appUser);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex,
|
||||
$"Failed to get data for NewDPEligibleLoanSaleActivity with sourceId: {activity.MapToActivity().SourceId}. Falling back to basic mapping.");
|
||||
}
|
||||
|
||||
var mappedActivity = activity.MapToActivity();
|
||||
mappedActivity.AppUserId = appUser?.Id ?? Guid.Empty;
|
||||
mappedActivity.EmployeeId = appUser?.EmployeeId;
|
||||
mappedActivity.DepartmentId = department?.Id ?? -1;
|
||||
return mappedActivity;
|
||||
}
|
||||
|
||||
public async Task<AppUser> SearchForUser(UserSearchRequest userSearchRequest)
|
||||
{
|
||||
var foundUsers = await _userService.GetAllUsersAsync(userSearchRequest);
|
||||
|
||||
if (foundUsers.Count < 1 && !string.IsNullOrWhiteSpace(userSearchRequest.MiddleInit))
|
||||
{
|
||||
foundUsers = await _userService.GetAllUsersAsync(new UserSearchRequest()
|
||||
{
|
||||
FirstName = userSearchRequest.FirstName,
|
||||
LastName = userSearchRequest.LastName,
|
||||
DnaOrgNbr = userSearchRequest.DnaOrgNbr
|
||||
});
|
||||
}
|
||||
|
||||
if (foundUsers.Count < 1)
|
||||
{
|
||||
foundUsers = await _userService.GetAllUsersAsync(new UserSearchRequest()
|
||||
{
|
||||
FirstName = userSearchRequest.FirstName,
|
||||
LastName = userSearchRequest.LastName,
|
||||
});
|
||||
}
|
||||
|
||||
return foundUsers.Single();
|
||||
}
|
||||
}
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
using LCU.API.Internal.Operations.IncentiveApi.Models.DataTransfer;
|
||||
using LCU.API.Internal.Operations.IncentiveApi.Models.ExternalActivities;
|
||||
using LCU.API.Internal.Operations.IncentiveApiLib.Services;
|
||||
using LCU.API.Internal.Operations.IncentiveApiLib.Repositories;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Entities;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Enums;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Requests;
|
||||
using LCU.API.Internal.Operations.IncentiveApi.Models.Constants;
|
||||
|
||||
namespace LCU.API.Internal.Operations.IncentiveApi.Services.ExternalActivity;
|
||||
|
||||
public class NewMortgageActivityStrategy : IExternalActivityStrategy
|
||||
{
|
||||
private readonly IUserService _userService;
|
||||
private readonly IDepartmentRepository _departmentRepository;
|
||||
|
||||
public NewMortgageActivityStrategy(IUserService userService, IDepartmentRepository departmentRepository)
|
||||
{
|
||||
_userService = userService;
|
||||
_departmentRepository = departmentRepository;
|
||||
}
|
||||
|
||||
public bool CanMapActivity(IExternalActivity activity)
|
||||
{
|
||||
return
|
||||
activity.GetActivityType() == ActivityType.Sale
|
||||
&& (activity.GetProductType() == Product.Mortgage || activity.GetProductType() == Product.FirstMortgageReferral);
|
||||
}
|
||||
|
||||
public async Task<Activity> MapToActivityManagerActivity(IExternalActivity activity)
|
||||
{
|
||||
AppUser appUser = null;
|
||||
Department department = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (activity is NewLoanSaleActivity newMortgageActivity)
|
||||
{
|
||||
if (IsFirstMortgageSale(newMortgageActivity))
|
||||
{
|
||||
appUser = await _userService.GetUserByAdEmailAsync(SystemAppUserConstants.FirstMortgageEmail);
|
||||
}
|
||||
else if (string.IsNullOrWhiteSpace(newMortgageActivity.EmployeeEmail))
|
||||
{
|
||||
appUser = await _userService.TryFindSingleUserByName(new UserNameSearchRequest()
|
||||
{
|
||||
FirstName = newMortgageActivity.AssociateFirst,
|
||||
LastName = newMortgageActivity.AssociateLast,
|
||||
MiddleInit = newMortgageActivity.AssociateMiddleInit,
|
||||
DnaOrgNbr = newMortgageActivity.BranchOrgNbr.ToString()
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
appUser = await _userService.GetUserByAdEmailAsync(newMortgageActivity.EmployeeEmail);
|
||||
}
|
||||
|
||||
if (appUser == null)
|
||||
{
|
||||
return activity.MapToActivity();
|
||||
}
|
||||
|
||||
department = await _departmentRepository.FindUserHomeDepartment(appUser);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex,
|
||||
$"Failed to get data for NewMortgageSaleActivity with sourceId: {activity.MapToActivity().SourceId}. Falling back to basic mapping.");
|
||||
}
|
||||
|
||||
var mappedActivity = activity.MapToActivity();
|
||||
mappedActivity.AppUserId = appUser?.Id ?? Guid.Empty;
|
||||
mappedActivity.EmployeeId = appUser?.EmployeeId;
|
||||
mappedActivity.DepartmentId = department?.Id ?? -1;
|
||||
return mappedActivity;
|
||||
}
|
||||
|
||||
private bool IsFirstMortgageSale(NewLoanSaleActivity newMortgageActivity)
|
||||
{
|
||||
if (newMortgageActivity.GetProductType() == Product.FirstMortgageReferral
|
||||
&& newMortgageActivity.GetActivityType() == ActivityType.Sale)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public async Task<AppUser> SearchForUser(UserSearchRequest userSearchRequest)
|
||||
{
|
||||
var foundUsers = await _userService.GetAllUsersAsync(userSearchRequest);
|
||||
|
||||
if (foundUsers.Count < 1 && !string.IsNullOrWhiteSpace(userSearchRequest.MiddleInit))
|
||||
{
|
||||
foundUsers = await _userService.GetAllUsersAsync(new UserSearchRequest()
|
||||
{
|
||||
FirstName = userSearchRequest.FirstName,
|
||||
LastName = userSearchRequest.LastName,
|
||||
DnaOrgNbr = userSearchRequest.DnaOrgNbr
|
||||
});
|
||||
}
|
||||
|
||||
if (foundUsers.Count < 1)
|
||||
{
|
||||
foundUsers = await _userService.GetAllUsersAsync(new UserSearchRequest()
|
||||
{
|
||||
FirstName = userSearchRequest.FirstName,
|
||||
LastName = userSearchRequest.LastName,
|
||||
});
|
||||
}
|
||||
return foundUsers.Single();
|
||||
}
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
using LCU.API.Internal.Operations.IncentiveApi.Models.DataTransfer;
|
||||
using LCU.API.Internal.Operations.IncentiveApi.Models.ExternalActivities;
|
||||
using LCU.API.Internal.Operations.IncentiveApiLib.Services;
|
||||
using LCU.API.Internal.Operations.IncentiveApiLib.Repositories;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Entities;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Enums;
|
||||
|
||||
namespace LCU.API.Internal.Operations.IncentiveApi.Services.ExternalActivity;
|
||||
|
||||
public class NewVehicleActivityStrategy : IExternalActivityStrategy
|
||||
{
|
||||
private readonly IUserService _userService;
|
||||
private readonly IDepartmentRepository _departmentRepository;
|
||||
|
||||
public NewVehicleActivityStrategy(IUserService userService, IDepartmentRepository departmentRepository)
|
||||
{
|
||||
_userService = userService;
|
||||
_departmentRepository = departmentRepository;
|
||||
}
|
||||
|
||||
public bool CanMapActivity(IExternalActivity activity)
|
||||
{
|
||||
return activity.GetActivityType() == ActivityType.Sale && activity.GetProductType() == Product.Vehicle;
|
||||
}
|
||||
|
||||
public async Task<Activity> MapToActivityManagerActivity(IExternalActivity activity)
|
||||
{
|
||||
AppUser appUser = null;
|
||||
Department department = null;
|
||||
try
|
||||
{
|
||||
if (activity is NewLoanSaleActivity newVehicleActivity)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(newVehicleActivity.EmployeeEmail))
|
||||
{
|
||||
try
|
||||
{
|
||||
appUser = await _userService.TryFindSingleUserByName(new UserNameSearchRequest()
|
||||
{
|
||||
FirstName = newVehicleActivity.AssociateFirst,
|
||||
LastName = newVehicleActivity.AssociateLast,
|
||||
MiddleInit = newVehicleActivity.AssociateMiddleInit,
|
||||
DnaOrgNbr = newVehicleActivity.BranchOrgNbr.ToString()
|
||||
});
|
||||
}
|
||||
catch (InvalidOperationException ioe)
|
||||
{
|
||||
Log.Error(ioe,
|
||||
$"More than one user found for name query {newVehicleActivity.AssociateFirst}, {newVehicleActivity.AssociateLast}, will try employee email.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
appUser = await _userService.GetUserByAdEmailAsync(newVehicleActivity.EmployeeEmail);
|
||||
}
|
||||
|
||||
if (appUser == null)
|
||||
{
|
||||
return activity.MapToActivity();
|
||||
}
|
||||
|
||||
department = await _departmentRepository.FindUserHomeDepartment(appUser);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex,
|
||||
$"Failed to get data for NewVehicleActivityStrategy with sourceId: {activity.MapToActivity().SourceId}. Falling back to basic mapping.");
|
||||
}
|
||||
|
||||
var mappedActivity = activity.MapToActivity();
|
||||
mappedActivity.AppUserId = appUser?.Id ?? Guid.Empty;
|
||||
mappedActivity.EmployeeId = appUser?.EmployeeId;
|
||||
mappedActivity.DepartmentId = department?.Id ?? -1;
|
||||
return mappedActivity;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user