public async Task <ActionResult> CreateFeeSetting(CreateProjectFeeSettingViewModel viewModel) { var project = await ProjectRepository.GetProjectAsync(viewModel.ProjectId); if (project == null) { return(HttpNotFound()); } try { await FinanceService.CreateFeeSetting(new CreateFeeSettingRequest() { ProjectId = viewModel.ProjectId, Fee = viewModel.Fee, PreferentialFee = viewModel.PreferentialFee, StartDate = viewModel.StartDate, }); return(RedirectToAction("Setup", new { viewModel.ProjectId })); } catch { //TODO: Message that comment is not added return(RedirectToAction("Setup", new { viewModel.ProjectId })); } }
public async Task <ActionResult> TogglePaymentType(TogglePaymentTypeViewModel data) { try { if (data.PaymentTypeId > 0) { await FinanceService.TogglePaymentActiveness(data.ProjectId, data.PaymentTypeId.Value); } else { await FinanceService.CreatePaymentType(new CreatePaymentTypeRequest { ProjectId = data.ProjectId, TargetMasterId = data.MasterId, TypeKind = (PaymentTypeKind)data.TypeKind.GetValueOrDefault(PaymentTypeKindViewModel.Custom), }); } return(RedirectToAction("Setup", new { projectid = data.ProjectId })); } catch { //TODO: Message that payment type was not created return(RedirectToAction("Setup", new { projectid = data.ProjectId })); } }
public TransactionEntry AddSymbol(string exchange, string symbol, PortfolioEntry entry) { PositionFeed positionFeed = FinanceService.Query(new PositionQuery(entry.EditUri.Content + FinanceNamespace.POSITIONAPPENDQUERY + Details())); TransactionEntry transactionEntry = new TransactionEntry() { TransactionData = new TransactionData() { Type = TransactionTypes.BUY } }; PositionEntry positionEntry = new PositionEntry() { Symbol = new Symbol() { StockSymbol = symbol, Exchange = exchange } }; Uri uri = new Uri(positionFeed.Feed + "/" + positionEntry.Symbol.Exchange + ":" + positionEntry.Symbol.StockSymbol + "/" + FinanceNamespace.TRANSACTIONS); try { return(FinanceService.Insert(uri, transactionEntry)); } catch (Exception ex) { Console.WriteLine("Exception while trying to add symbol={0} to portfolio={1}", symbol + ":" + exchange, entry.Title.Text); Console.WriteLine("Exception: {0}", ex.Message); return(null); } }
public async Task <ActionResult> ChangeSettings(FinanceGlobalSettingsViewModel viewModel) { var project = await ProjectRepository.GetProjectAsync(viewModel.ProjectId); if (project == null) { return(HttpNotFound()); } try { await FinanceService.SaveGlobalSettings(new SetFinanceSettingsRequest { ProjectId = viewModel.ProjectId, WarnOnOverPayment = viewModel.WarnOnOverPayment, PreferentialFeeEnabled = viewModel.PreferentialFeeEnabled, PreferentialFeeConditions = viewModel.PreferentialFeeConditions, }); return(RedirectToAction("Setup", new { viewModel.ProjectId })); } catch { //TODO: Message that comment is not added return(RedirectToAction("Setup", new { viewModel.ProjectId })); } }
public async Task <ActionResult> MarkPreferential(int claimid, int projectid, bool preferential) { try { if (!ModelState.IsValid) { return(await Edit(projectid, claimid)); } await FinanceService.MarkPreferential(new MarkPreferentialRequest { ProjectId = projectid, ClaimId = claimid, Preferential = preferential, }); return(RedirectToAction("Edit", "Claim", new { claimid, projectid })); } catch { return(await Edit(projectid, claimid)); } }
/// <summary> /// Create a portfolio /// </summary> /// <param name="title">Name of the portfolio</param> /// <param name="portfolioData">Settings for the portfolio</param> /// <returns>Returns the response from the server</returns> public PortfolioEntry CreatePortfolio(string title, PortfolioData portfolioData) { // Create a new entry. PortfolioEntry entry = new PortfolioEntry(); // Set the name of the portfolio entry.Title.Text = title; // Set the portfolio data entry.PortfolioData = portfolioData; // Default to USD if (entry.PortfolioData.CurrencyCode.Length == 0) { entry.PortfolioData.CurrencyCode = "USD"; } // Return the response from the server. try { return(FinanceService.Insert(new Uri(FinanceNamespace.PORTFOLIOS), entry)); } catch (GDataRequestException ex) { Console.WriteLine("Unable to create portfolio, Exception: {0}", ex.Message); return(null); } }
public async Task <ActionResult> TogglePaymentType(int projectid, int paymentTypeId) { var project = await ProjectRepository.GetProjectAsync(projectid); var errorResult = AsMaster(project, acl => acl.CanManageMoney); if (errorResult != null) { return(errorResult); } try { if (paymentTypeId < 0) { await FinanceService.CreateCashPaymentType(projectid, CurrentUserId, -paymentTypeId); } else { await FinanceService.TogglePaymentActivness(projectid, CurrentUserId, paymentTypeId); } return(RedirectToAction("Setup", new { projectid })); } catch { //TODO: Message that comment is not added return(RedirectToAction("Setup", new { projectid })); } }
public async Task <ActionResult> TransferClaimPayment(PaymentTransferViewModel data) { try { await FinanceService.TransferPaymentAsync( new ClaimPaymentTransferRequest { ProjectId = data.ProjectId, ClaimId = data.ClaimId, ToClaimId = data.RecipientClaimId, CommentText = data.CommentText, OperationDate = data.OperationDate, Money = data.Money, }); return(RedirectToAction( "Edit", "Claim", new { projectId = data.ProjectId, claimId = data.ClaimId })); } catch (Exception e) { return(View("Error", new ErrorViewModel { Title = "Перевод между заявками", Message = $"Ошибка выполнения перевода {data.Money} от заявки {data.ClaimId} к заявке {data.RecipientClaimId}", Description = e.Message, Data = e, ReturnLink = Url.Action("Edit", "Claim", new { projectId = data.ProjectId, claimId = data.ClaimId }), ReturnText = "Вернуться к заявке" })); } }
protected void InitTasks() { var iRPCSDbAccessor = (IRPCSDbAccessor) new RPCSSingletonDbAccessor(_rpcsContextOptions); var rPCSRepositoryFactory = (IRepositoryFactory) new RPCSRepositoryFactory(iRPCSDbAccessor); var userService = (IUserService) new UserService(rPCSRepositoryFactory, _httpContextAccessor); var tsAutoHoursRecordService = (ITSAutoHoursRecordService) new TSAutoHoursRecordService(rPCSRepositoryFactory, userService); var vacationRecordService = (IVacationRecordService) new VacationRecordService(rPCSRepositoryFactory, userService); var reportingPeriodService = (IReportingPeriodService) new ReportingPeriodService(rPCSRepositoryFactory); var productionCalendarService = (IProductionCalendarService) new ProductionCalendarService(rPCSRepositoryFactory); var tsHoursRecordService = (ITSHoursRecordService) new TSHoursRecordService(rPCSRepositoryFactory, userService, _tsHoursRecordServiceLogger); var projectService = (IProjectService) new ProjectService(rPCSRepositoryFactory, userService); var departmemtService = new DepartmentService(rPCSRepositoryFactory, userService); var employeeService = (IEmployeeService) new EmployeeService(rPCSRepositoryFactory, departmemtService, userService); var projectMembershipService = (IProjectMembershipService) new ProjectMembershipService(rPCSRepositoryFactory); var projectReportRecords = new ProjectReportRecordService(rPCSRepositoryFactory); var employeeCategoryService = new EmployeeCategoryService(rPCSRepositoryFactory); var applicationUserService = new ApplicationUserService(rPCSRepositoryFactory, employeeService, userService, departmemtService, _httpContextAccessor, _memoryCache, projectService, _onlyofficeOptions); var appPropertyService = new AppPropertyService(rPCSRepositoryFactory, _adOptions, _bitrixOptions, _onlyofficeOptions, _timesheetOptions); var financeService = new FinanceService(rPCSRepositoryFactory, iRPCSDbAccessor, applicationUserService, appPropertyService, _ooService); var timesheetService = new TimesheetService(employeeService, employeeCategoryService, tsAutoHoursRecordService, tsHoursRecordService, projectService, projectReportRecords, vacationRecordService, productionCalendarService, financeService, _timesheetOptions); var projectExternalWorkspaceService = new ProjectExternalWorkspaceService(rPCSRepositoryFactory); var jiraService = new JiraService(userService, _jiraOptions, projectExternalWorkspaceService, projectService); _taskTimesheetProcessing = new TimesheetProcessingTask(tsAutoHoursRecordService, vacationRecordService, reportingPeriodService, productionCalendarService, tsHoursRecordService, userService, projectService, employeeService, projectMembershipService, timesheetService, _timesheetOptions, _smtpOptions, _jiraOptions, jiraService, projectExternalWorkspaceService); }
private void TestClients(object listClients) { if (!(listClients is List <Client> castedListClients)) { return; } foreach (var client in castedListClients) { var startBalance = client.AccountBalance; // Enrollment amount knowingly more than withdrawal amount to avoid exceptions var enrollmentAmount = Random.Next(1000, 2000); var withdrawalAmount = Random.Next(500, 900); var expectedBalance = startBalance + enrollmentAmount - withdrawalAmount; lock (Locker) { Task.Run(() => FinanceService.EnrollAsync(new ClientOperationDto() { Id = client.Id, TransactionAmount = enrollmentAmount })).Wait(); Task.Run(() => FinanceService.WithdrawAsync(new ClientOperationDto() { Id = client.Id, TransactionAmount = withdrawalAmount })).Wait(); var currentBalance = Task.Run(() => FinanceService.GetBalanceByIdAsync(client.Id)).Result; if (expectedBalance != currentBalance) { IsErrors = true; break; } } } }
public async Task <ActionResult> FinanceOperation(FeeAcceptanceViewModel viewModel) { var claim = await _claimsRepository.GetClaim(viewModel.ProjectId, viewModel.ClaimId); var error = WithClaim(claim); if (error != null) { return(error); } try { if (!ModelState.IsValid) { return(await Edit(viewModel.ProjectId, viewModel.ClaimId)); } await FinanceService.FeeAcceptedOperation(claim.ProjectId, claim.ClaimId, CurrentUserId, viewModel.CommentText, viewModel.OperationDate, viewModel.FeeChange, viewModel.Money, viewModel.PaymentTypeId); return(RedirectToAction("Edit", "Claim", new { viewModel.ClaimId, viewModel.ProjectId })); } catch { return(await Edit(viewModel.ProjectId, viewModel.ClaimId)); } }
public async Task <ActionResult> CreateFeeSetting(CreateProjectFeeSettingViewModel viewModel) { var project = await ProjectRepository.GetProjectAsync(viewModel.ProjectId); var errorResult = AsMaster(project, acl => acl.CanManageMoney); if (errorResult != null) { return(errorResult); } try { await FinanceService.CreateFeeSetting(new CreateFeeSettingRequest() { ProjectId = viewModel.ProjectId, Fee = viewModel.Fee, PreferentialFee = viewModel.PreferentialFee, StartDate = viewModel.StartDate, }); return(RedirectToAction("Setup", new { viewModel.ProjectId })); } catch { //TODO: Message that comment is not added return(RedirectToAction("Setup", new { viewModel.ProjectId })); } }
public async Task <ActionResult> ChangeFee(int claimid, int projectid, int feeValue) { var claim = await _claimsRepository.GetClaim(projectid, claimid); var error = WithClaim(claim); if (error != null) { return(error); } try { if (!ModelState.IsValid) { return(await Edit(projectid, claimid)); } await FinanceService.ChangeFee(claim.ProjectId, claim.ClaimId, feeValue, CurrentUserId); return(RedirectToAction("Edit", "Claim", new { claimid, projectid })); } catch { return(await Edit(projectid, claimid)); } }
public static void PlaceOrderAndPay(string sourceAccount, string destinationAccount, string description, decimal amount) { OrderService.PlaceOrder(description, amount); FinanceService.Transfer(sourceAccount, destinationAccount, amount, description); }
public void Query() { var service = new FinanceService(); int count; var list = service.GetFinanceList("C070541", new PageCondition(1, 2), out count); Assert.IsTrue(list.Count == 2); }
public void DeleteSymbol(PositionEntry positionEntry) { TransactionFeed transactionFeed = FinanceService.Query(new TransactionQuery(positionEntry.TransactionHerf + Details())); //+ FinanceNamespace.TRANSACTIONSAPPENDQUERY)); foreach (TransactionEntry transactionEntry in transactionFeed.Entries) { FinanceService.Delete(new Uri(transactionEntry.EditUri.Content)); } }
public async Task HandleStockCommand(IDialogContext context, string messageText) { //string StockRateString = await FinanceService.GetStock(messageText.Replace("#Stock ", "")); string StockRateString = await FinanceService.GetStock("ibm"); await context.PostAsync(StockRateString); context.Wait(MessageReceived); }
public async Task OnGetAsync() { People = await personService.GetPeopleAsync(); decimal monthlyIncome = FinanceService.GetTotalMonthlyIncome(People); decimal yearlyIncome = FinanceService.GetTotalYearlyIncome(People); TotalMonthlyIncome = FinanceService.FormatToCurrencyString(monthlyIncome); TotalYearlyIncome = FinanceService.FormatToCurrencyString(yearlyIncome); }
public TransactionEntry AddSymbol(string exchange, string symbol, TransactionDataArgs args, PortfolioEntry entry) { PositionFeed positionFeed = FinanceService.Query(new PositionQuery(entry.EditUri.Content + FinanceNamespace.POSITIONAPPENDQUERY + Details())); TransactionEntry transactionEntry = new TransactionEntry() { TransactionData = new TransactionData() { Type = args.TransactionType, Date = args.Date.ToString(), Shares = args.Shares, Notes = args.Notes, Commission = new Commission(), Price = new Price() } }; PositionEntry positionEntry = new PositionEntry() { Symbol = new Symbol() { StockSymbol = symbol, Exchange = exchange } }; transactionEntry.TransactionData.Commission.Money.Add(new Money() { Amount = args.Commission, CurrencyCode = args.CurrencyCode }); transactionEntry.TransactionData.Price.Money.Add(new Money() { Amount = args.Price, CurrencyCode = args.CurrencyCode }); Uri uri = new Uri(positionFeed.Feed + "/" + positionEntry.Symbol.Exchange + ":" + positionEntry.Symbol.StockSymbol + "/" + FinanceNamespace.TRANSACTIONS); try { return(FinanceService.Insert(uri, transactionEntry)); } catch (Exception ex) { Console.WriteLine("Exception while trying to add symbol={0} to portfolio={1} and transaction: ", positionEntry.Symbol.Exchange + ":" + positionEntry.Symbol.StockSymbol, entry.Title.Text); Console.WriteLine("Type={0}, Date={1}, Shares={2}, Notes={3}, Commission={4}, Price={5}", transactionEntry.TransactionData.Type, transactionEntry.TransactionData.Date, transactionEntry.TransactionData.Shares, transactionEntry.TransactionData.Notes, transactionEntry.TransactionData.Commission, transactionEntry.TransactionData.Price); Console.WriteLine("Exception: {0}", ex.Message); return(null); } }
private async Task ResumeAfterLuisDialog(IDialogContext context, IAwaitable <object> result) { string message = $"Now, i'm using LUIS "; string _result = await FinanceService.GetEntityFromLUIS("one person in this hotel"); await context.PostAsync(message); await context.PostAsync(_result); context.Wait(this.MessageReceivedAsync); }
public void Setup() { MapperConfiguration mappingConfig = new MapperConfiguration(mc => { mc.AddProfile(new MappingFinance <FinanceData>()); }); IMapper mapper = mappingConfig.CreateMapper(); financeService = new FinanceService <FinanceData>(workingWithFinanceForTest, mapper); }
// TODO: add the detailed query here also. public Dictionary <string, PositionEntry> RetrieveSymbols(PortfolioEntry entry) { PositionFeed positionFeed = FinanceService.Query(new PositionQuery(entry.EditUri.Content + FinanceNamespace.POSITIONAPPENDQUERY + Details())); Dictionary <string, PositionEntry> symbols = new Dictionary <string, PositionEntry>(); foreach (PositionEntry positionEntry in positionFeed.Entries) { symbols.Add(positionEntry.Symbol.Exchange + ":" + positionEntry.Symbol.StockSymbol, positionEntry); } return(symbols); }
public List <TransactionEntry> RetrieveSymbolTransaction(PositionEntry entry) { TransactionFeed transactionFeed = FinanceService.Query(new TransactionQuery(entry.TransactionHerf + Details())); List <TransactionEntry> transactionEntries = new List <TransactionEntry>(); //transactionFeed.Entries.ToList<AtomEntryCollection>().ForEach(t => transactionEntries.Add(t)); foreach (TransactionEntry te in transactionFeed.Entries) { transactionEntries.Add(te); } return(transactionEntries); }
public async Task <ActionResult> CreatePaymentType(CreatePaymentTypeViewModel viewModel) { try { await FinanceService.CreateCustomPaymentType(viewModel.ProjectId, viewModel.Name, viewModel.UserId); return(RedirectToAction("Setup", new { viewModel.ProjectId })); } catch { //TODO: Message that comment is not added return(RedirectToAction("Setup", new { viewModel.ProjectId })); } }
public GoogleFinanceManager(string username, string passsword) { FinanceService = new FinanceService("GoogleFinanceManager"); FinanceService.setUserCredentials(username, passsword); if (ConfigurationSettings.AppSettings["DEBUG_LOG"] == "true") { // Debugging requests and inserts. GDataLoggingRequestFactory factoryLogging = new GDataLoggingRequestFactory("finance", ".NETSDK Finance"); factoryLogging.MethodOverride = true; factoryLogging.CombinedLogFileName = ConfigurationSettings.AppSettings["DEBUG_LOGFILE"]; FinanceService.RequestFactory = factoryLogging; } }
public async Task <ActionResult> ChangeFee(int claimid, int projectid, int feeValue) { try { if (!ModelState.IsValid) { return(await Edit(projectid, claimid)); } await FinanceService.ChangeFee(projectid, claimid, feeValue); return(RedirectToAction("Edit", "Claim", new { claimid, projectid })); } catch { return(await Edit(projectid, claimid)); } }
public void FinanceService_MakeTransaction_Integration() { ApplicationClientService appClient = new ApplicationClientService(); FinanceService financeService = new FinanceService(); string firstUserId = appClient.RegisterNewBankClient(new BankClientDto() { FirstName = "Serik", LastName = "Serik", Email = "*****@*****.**", PasswordHash = "12345", ApplicationClientType = ApplicationClientType.BankClient, }); string secondUserId = appClient.RegisterNewBankClient(new BankClientDto() { FirstName = "Alika", LastName = "Alika", Email = "*****@*****.**", PasswordHash = "12345", ApplicationClientType = ApplicationClientType.BankClient, }); // S = -100, A = +100 financeService.MakeClientToClientTransaction(firstUserId, secondUserId, 100M); // S = -150, A = +150 financeService.MakeClientToClientTransaction(firstUserId, secondUserId, 50M); // S = -110 A = +110 financeService.MakeClientToClientTransaction(secondUserId, firstUserId, 40M); var resultForUserOne = financeService.GetHistoryOverview(firstUserId); var resultForUserTwo = financeService.GetHistoryOverview(secondUserId); Debug.WriteLine(resultForUserOne.Item1 + " " + resultForUserOne.Item2); Debug.WriteLine(resultForUserTwo.Item1 + " " + resultForUserTwo.Item2); Assert.IsTrue(resultForUserOne.Item1 == 150M && resultForUserOne.Item2 == 40M); Assert.IsTrue(resultForUserTwo.Item1 == 40M && resultForUserTwo.Item2 == 150M); }
public async Task <ActionResult> CreatePaymentType(CreatePaymentTypeViewModel viewModel) { try { await FinanceService.CreatePaymentType(new CreatePaymentTypeRequest { ProjectId = viewModel.ProjectId, TargetMasterId = viewModel.UserId, TypeKind = PaymentTypeKind.Custom, Name = viewModel.Name, }); return(RedirectToAction("Setup", new { viewModel.ProjectId })); } catch { //TODO: Message that comment is not added return(RedirectToAction("Setup", new { viewModel.ProjectId })); } }
public async Task <ActionResult> FinanceOperation(FeeAcceptanceViewModel viewModel) { var claim = await _claimsRepository.GetClaim(viewModel.ProjectId, viewModel.ClaimId); if (claim == null) { return(HttpNotFound()); } var error = WithClaim(claim); if (error != null) { return(error); } try { if (!ModelState.IsValid) { return(await Edit(viewModel.ProjectId, viewModel.ClaimId)); } await FinanceService.FeeAcceptedOperation(new FeeAcceptedOperationRequest() { ProjectId = claim.ProjectId, ClaimId = claim.ClaimId, Contents = viewModel.CommentText, FeeChange = viewModel.FeeChange, Money = viewModel.Money, OperationDate = viewModel.OperationDate, PaymentTypeId = viewModel.PaymentTypeId, }); return(RedirectToAction("Edit", "Claim", new { viewModel.ClaimId, viewModel.ProjectId })); } catch { return(await Edit(viewModel.ProjectId, viewModel.ClaimId)); } }
public async Task <ActionResult> DeleteFeeSetting(int projectid, int projectFeeSettingId) { var project = await ProjectRepository.GetProjectAsync(projectid); if (project == null) { return(HttpNotFound()); } try { await FinanceService.DeleteFeeSetting(projectid, projectFeeSettingId); return(RedirectToAction("Setup", new { projectid })); } catch { //TODO: Message that comment is not added return(RedirectToAction("Setup", new { projectid })); } }