public static async Task <ActionResult> Initialise(IConfiguration configuration) { try { Logger = new ConsoleLogger(); IMapper mapper = Mapper.CreateAndInitialiseMappings(Logger); ActionResult createPersistorResult = CreatePersistor(configuration, out IPersistor persistor); if (!createPersistorResult.IsSuccess) { return(createPersistorResult); } var accountingDataAccess = new AccountingDataAccess(persistor, Logger); var accountingEngine = new AccountingEngine(accountingDataAccess, Logger); AccountingManager = new AccountingManager( accountingEngine, accountingDataAccess, mapper, Logger); return(await AccountingManager.Initialise()); } catch (Exception ex) { var message = $"Unhandled exception: \"{ex.Message}\"."; Logger?.LogError(message, ex); return(ActionResult.CreateFailure(message)); } }
public TrainingBudgetPresenter(ITrainingBudgetView view) { ServiceLocator serviceLocator = ServiceLocator.GetInstance(); this.view = view; this.acct = serviceLocator.Get <IAccountingManager>(); this.hr = serviceLocator.Get <IHRManager>(); }
public AddPeriodDialog(IAccountingManager accountingManager) { _accountingManager = accountingManager ?? throw new ArgumentNullException(nameof(accountingManager)); _synchronizationContext = SynchronizationContext.Current; InitializeComponent(); }
public MainForm( IAccountingManager accountingManager, ILogger logger) { _accountingManager = accountingManager ?? throw new ArgumentNullException(nameof(accountingManager)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _synchronizationContext = SynchronizationContext.Current; InitializeComponent(); }
/// <summary> /// Charges the Accounting service for the cost of the course registration. /// </summary> /// <param name="web">The SPWeb in the current workflow context.</param> /// <param name="workflowItem">The SPListItem that the workflow instance is associated with.</param> public void ChargeAccounting(SPWeb web, SPListItem workflowItem) { IHRManager hrManager = serviceLocator.Get <IHRManager>(); IAccountingManager accountingManager = serviceLocator.Get <IAccountingManager>(); IRegistrationRepository registrationRepository = serviceLocator.Get <IRegistrationRepository>(); ITrainingCourseRepository trainingCourseRepository = serviceLocator.Get <ITrainingCourseRepository>(); //get registration and training course related to this task. Registration registration = registrationRepository.Get(workflowItem.ID, web); TrainingCourse trainingCourse = trainingCourseRepository.Get(registration.CourseId, web); //get the user related to this registration SPUser user = GetSPUser(web, registration.UserId); //construct the transaction related to this approved registration Transaction tran = new Transaction(); tran.Amount = trainingCourse.Cost; tran.CostCenter = hrManager.GetCostCenter(user.LoginName); tran.Bucket = trainingBucketString; tran.Description = String.Format("{0} training course registration by {1}.", trainingCourse.Title, user.Name); accountingManager.SaveTransaction(tran); }
public TransactionPropertiesDialog(IAccountingManager accountingManager) { _accountingManager = accountingManager ?? throw new ArgumentNullException(nameof(accountingManager)); InitializeComponent(); }