public void DoTransfer(TransferBankCloudInputModel model, Account grantAccount, Account receiverAccount) { grantAccount.Balance -= model.Amount; if (receiverAccount.CurrencyId != grantAccount.CurrencyId) { ExchangeRate rateFromTo = Fixer .Rate(grantAccount.Currency.IsoCode, receiverAccount.Currency.IsoCode); var convertAmmount = rateFromTo.Convert((double)model.Amount); receiverAccount.Balance += (decimal)convertAmmount; model.ConvertedAmount = (decimal)convertAmmount; } else { receiverAccount.Balance += model.Amount; model.ConvertedAmount = model.Amount; } Transfer transfer = this.mapper.Map <Transfer>(model); transfer.ForeignAccountId = receiverAccount.Id; transfer.Date = DateTime.UtcNow; transfer.Completed = DateTime.UtcNow; transfer.Type = TransferType.BankCloud; transfer.Status = TransferStatus.Approved; transfer.BalanceType = BalanceType.Negative; this.context.Transfers.Add(transfer); this.context.SaveChanges(); }
public IActionResult ChargeBankCloud(string iban) { var chargeData = TempData.Get <AccountsChargeInputModel>("charge"); var bankCloudCharge = this.mapper.Map <ChargeBankCloudInputModel>(chargeData); var grantAccount = this.accountsService.GetAccountByIban(iban); if (grantAccount == null || bankCloudCharge.Id == grantAccount.Id) { this.TempData["error"] = GlobalConstants.MISSING_BANKCLOUD_ACCOUNT; return(this.RedirectToAction("Charge", chargeData)); } Transfer transfer = this.mapper.Map <Transfer>(bankCloudCharge); if (grantAccount.Currency.IsoCode != bankCloudCharge.IsoCode) { ExchangeRate rateFromTo = Fixer .Rate(bankCloudCharge.IsoCode, grantAccount.Currency.IsoCode); var convertedAmount = rateFromTo.Convert((double)bankCloudCharge.Amount); transfer.ConvertedAmount = (decimal)convertedAmount; } else { transfer.ConvertedAmount = bankCloudCharge.Amount; } transfer.ForeignAccountId = grantAccount.Id; transfer.BalanceType = BalanceType.Positive; this.transferService.AddBankCloudTransfer(transfer); return(this.Redirect("/Accounts/Index")); }
public void FixTrunkRemoteBranchHasTrunkBranchIsNotRebaseTest() { // Prepare var mock = new Mock <ICommandRunner>(); mock.Setup(f => f.Run("git", It.IsAny <string>())) .Returns(0); MetaInfo metaInfo = new MetaInfo() { RemoteBranches = new List <string>() { "trunk" } }; Options option = new Options() { Rebase = false }; IFixer fixer = new Fixer(metaInfo, option, mock.Object, "", null, null); // Act fixer.FixTrunk(); // Assert mock.Verify(f => f.Run("git", "checkout svn/trunk"), Times.Once()); mock.Verify(f => f.Run("git", "branch -D master"), Times.Once()); mock.Verify(f => f.Run("git", "checkout -f -b master"), Times.Once()); mock.Verify(f => f.Run("git", "checkout -f master"), Times.Never()); }
public async void CanFixStreamViaClass() { string inputFile = $"{Environment.CurrentDirectory}\\assets\\brokenbottle_class_stream.3mf"; string outputFile = $"{Environment.CurrentDirectory}\\assets\\brokenbottle_class_stream_fixed.3mf"; DeleteFile(outputFile); using var inputStream = File.OpenRead(inputFile); var fixer = new Fixer(); using (var stream = await fixer.FixAsync(inputStream)) { using var outfile = File.Create(outputFile); stream.Seek(0, SeekOrigin.Begin); stream.CopyTo(outfile); } var fileBytes = File.ReadAllBytes(outputFile); Assert.True(fileBytes.Length > 0); DeleteFile(outputFile); }
protected override async Task <Document> GetChangedSuppressionDocumentAsync( CancellationToken cancellationToken ) { var suppressionsDoc = await GetOrCreateSuppressionsDocumentAsync(cancellationToken) .ConfigureAwait(false); var workspace = suppressionsDoc.Project.Solution.Workspace; var suppressionsRoot = await suppressionsDoc .GetSyntaxRootAsync(cancellationToken) .ConfigureAwait(false); var compilation = await suppressionsDoc.Project .GetCompilationAsync(cancellationToken) .ConfigureAwait(false); var addImportsService = suppressionsDoc.GetRequiredLanguageService <IAddImportsService>(); suppressionsRoot = Fixer.AddGlobalSuppressMessageAttribute( suppressionsRoot, _targetSymbol, _suppressMessageAttribute, _diagnostic, workspace, compilation, addImportsService, cancellationToken ); return(suppressionsDoc.WithSyntaxRoot(suppressionsRoot)); }
private void button5_Click(object sender, EventArgs e) { string codeFileName = bug.Codes.CodeFileName; string codeFilePath = bug.Codes.CodeFilePath; string c = fastColoredTextBox1.Text; FixerDAO fixerDAO = new FixerDAO(); BugDAO bugDAO = new BugDAO(); Fixer fixer = new Fixer { FixedBy = Login.userId, BugId = Program.bugId }; try { fixerDAO.Insert(fixer); bugDAO.BugFixed(Program.bugId); MessageBox.Show("Oh great work"); this.Dispose(); new Bugs().Show(); } catch (Exception ex) { Console.WriteLine(ex.Message); } string path = "code/" + codeFileName + ".txt"; using (StreamWriter sw = File.CreateText(path)) { sw.WriteLine(c); } }
public async Task ConvCmdAsync(string amount, string from, [Remainder] string to) { amount = amount.Replace(',', '.'); if (!double.TryParse(amount, out var amountD)) { await Context.MarkCmdFailedAsync($"Unable to parse {amount} to double").ConfigureAwait(false); return; } if (to.StartsWith("to ", StringComparison.OrdinalIgnoreCase)) { to = to.Substring(3); } var result = await Fixer.ConvertAsync(from, to, amountD).ConfigureAwait(false); result = Math.Round(result, 2); var embed = new EmbedBuilder() .WithColor(Color.DarkGreen) .WithAuthor(new EmbedAuthorBuilder() .WithName(Context.User.GetNickname()) .WithIconUrl(Context.User.GetAvatarUrl() ?? Context.User.GetDefaultAvatarUrl())) .WithCurrentTimestamp() .WithDescription($"{amountD.ToString(CultureInfo.InvariantCulture)} {from.ToUpper()} = {result.ToString(CultureInfo.InvariantCulture).Bold()} {to.ToUpper().Bold()}"); await ReplyEmbedAsync(embed).ConfigureAwait(false); }
public static async Task fetchdata(string pair) { var client = new HttpClient(); var fullurl = "https://www.btcturk.com/api/ticker"; var result = await client.GetStringAsync(fullurl); RootObject r = JsonConvert.DeserializeObject <RootObject>(result); double tryRate = Fixer.Convert("TRY", "USD", 1); if (pair == "fiat") { tryData.ask = r.ask.ToString(); tryData.bid = r.bid.ToString(); tryData.last = r.last.ToString(); tryData.volume = r.volume.ToString(); tryData.high = r.high.ToString(); tryData.low = r.low.ToString(); tryData.pair = "TRY"; } else { usdData.ask = toString(r.ask * tryRate); usdData.bid = toString(r.bid * tryRate); usdData.last = toString(r.last * tryRate); usdData.volume = r.volume.ToString(); usdData.high = toString(r.high * tryRate); usdData.low = toString(r.low * tryRate); usdData.pair = "USD"; } //System.Diagnostics.Debug.WriteLine(usdData); }
public void FixBranchesIsNotRebaseIsNotTrunkBranchTest() { // Prepare var mock = new Mock <ICommandRunner>(); mock.Setup(f => f.Run("git", It.IsAny <string>())) .Returns(0); MetaInfo metaInfo = new MetaInfo() { LocalBranches = new List <string>() { "nodev" }, RemoteBranches = new List <string>() { "svn/dev" } }; Options options = new Options() { Rebase = false }; IFixer fixer = new Fixer(metaInfo, options, mock.Object, "", null, null); // Act fixer.FixBranches(); // Assert mock.Verify(f => f.Run("git", "checkout -b \"dev\" \"remotes/svn/dev\""), Times.Once()); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); System.Web.Http.GlobalConfiguration.Configure(WebApiConfig.Register); //WebApiConfig.Register(System.Web.Http.GlobalConfiguration.Configuration); //System.Web.Http.GlobalConfiguration.Configuration.EnsureInitialized(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); ModelBinders.Binders[typeof(DateTime)] = new DateTimeModelBinder(CommonFunctions.DATE_TIME_FORMAT); ModelBinders.Binders[typeof(DateTime?)] = new DateTimeModelBinder(CommonFunctions.DATE_TIME_FORMAT); //ModelBinders.Binders.Add(typeof(DateTime), new DateTimeModelBinder("dd.MM.yyyy HH:mm:ss")); //ModelBinders.Binders.Add(typeof(DateTime?), new DateTimeModelBinder("dd.MM.yyyy HH:mm:ss")); ModelBinders.Binders[typeof(Double)] = new DoubleModelBinder(); ModelBinders.Binders[typeof(Double?)] = new DoubleModelBinder(); //ModelBinders.Binders.Remove(typeof(byte[])); //ModelBinders.Binders.Add(typeof(byte[]), new CustomByteArrayModelBinder()); //ModelBinders.Binders[typeof(ImportDosarView)] = new CustomImportDosareModelBinder(); GlobalFilters.Filters.Add(new GlobalAntiForgeryTokenAttribute(false)); //System.Net.ServicePointManager.ServerCertificateValidationCallback += (se, cert, chain, sslerror) => true; Fixer.FixModelBindingIssue(); }
protected override async Task <Document> GetChangedSuppressionDocumentAsync(CancellationToken cancellationToken) { var suppressionsDoc = await GetOrCreateSuppressionsDocumentAsync(cancellationToken).ConfigureAwait(false); var workspace = suppressionsDoc.Project.Solution.Workspace; var suppressionsRoot = await suppressionsDoc.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); var compilation = await suppressionsDoc.Project.GetCompilationAsync(cancellationToken).ConfigureAwait(false); var addImportsService = suppressionsDoc.Project.LanguageServices.GetRequiredService <IAddImportsService>(); foreach (var kvp in _diagnosticsBySymbol) { var targetSymbol = kvp.Key; var diagnostics = kvp.Value; foreach (var diagnostic in diagnostics) { Contract.ThrowIfFalse(!diagnostic.IsSuppressed); suppressionsRoot = Fixer.AddGlobalSuppressMessageAttribute(suppressionsRoot, targetSymbol, diagnostic, workspace, compilation, addImportsService, cancellationToken); } } return(suppressionsDoc.WithSyntaxRoot(suppressionsRoot)); }
private void CreateLevelsMap() { GameObject fixerGO = Instantiate(fixerPrefab, currentPosition, Quaternion.identity); fixer = fixerGO.GetComponent <Fixer>(); currentPosition.x += pointsOffset; foreach (LevelSO level in levels) { GameObject arcadeMachine = Instantiate(arcadeMachinePrefab, currentPosition, Quaternion.identity); level.arcadeMachine = arcadeMachine.GetComponent <ArcadeMachine>(); currentPosition.x += pointsOffset; for (int i = 1; i < level.numberOfKidsNear + 1; i++) { switch (i) { case 1: Transform kid1Place = arcadeMachine.transform.Find("Kid1Place"); GameObject kid1 = Instantiate(kidsPrefabs[Random.Range(0, kidsPrefabs.Length)], kid1Place.position, Quaternion.identity); level.kid1 = kid1.GetComponent <Kid>(); break; case 2: Transform kid2Place = arcadeMachine.transform.Find("Kid2Place"); GameObject kid2 = Instantiate(kidsPrefabs[Random.Range(0, kidsPrefabs.Length)], kid2Place.position, Quaternion.identity); level.kid2 = kid2.GetComponent <Kid>(); break; } } } StartCoroutine(DisableAllArcadeMachines()); StartCoroutine(FixerToNextLevel(levels[currentLevelNumber])); }
public void ApproveSaveRequest(OrderSave orderedSave) { Account depositorAccount = orderedSave.Account; Account sellerAccount = orderedSave.Save.Account; double depositAmount = (double)orderedSave.Amount; double monthlyIncome = (double)orderedSave.MonthlyFee; if (depositorAccount.Currency.IsoCode != sellerAccount.Currency.IsoCode) { ExchangeRate rateFromTo = Fixer .Rate(sellerAccount.Currency.IsoCode, depositorAccount.Currency.IsoCode); depositAmount = rateFromTo.Convert(depositAmount); monthlyIncome = rateFromTo.Convert(monthlyIncome); } depositorAccount.Balance -= (decimal)depositAmount; depositorAccount.MonthlyIncome += (decimal)monthlyIncome; //TODO every mounts task transfer sellerAccount.Balance += orderedSave.Amount; sellerAccount.MonthlyOutcome += orderedSave.MonthlyFee; orderedSave.CompletedOn = DateTime.UtcNow; orderedSave.Status = OrderStatus.Approved; this.context.SaveChanges(); }
public void ApproveLoanRequest(OrderLoan orderLoan) { Account buyerAccount = orderLoan.Account; Account sellerAccount = orderLoan.Loan.Account; double orderCost = (double)orderLoan.Commission; double orderAmount = (double)orderLoan.Amount; double orderFee = (double)orderLoan.MonthlyFee; if (buyerAccount.Currency.IsoCode != sellerAccount.Currency.IsoCode) { ExchangeRate rateFromTo = Fixer .Rate(sellerAccount.Currency.IsoCode, buyerAccount.Currency.IsoCode); orderCost = rateFromTo.Convert(orderCost); orderAmount = rateFromTo.Convert(orderAmount); orderFee = rateFromTo.Convert(orderFee); } buyerAccount.Balance -= (decimal)orderCost; buyerAccount.Balance += (decimal)orderAmount; buyerAccount.MonthlyOutcome += (decimal)orderFee; sellerAccount.Balance += orderLoan.Commission; sellerAccount.Balance -= orderLoan.Amount; sellerAccount.MonthlyIncome += orderLoan.MonthlyFee; //TODO: every mounts task transfer orderLoan.CompletedOn = DateTime.UtcNow; orderLoan.Status = OrderStatus.Approved; this.context.SaveChanges(); }
private static void FixUpAssemblies(Fixer fixer, string searchPattern, string directory) { using (var catalog = new AggregateCatalog()) { foreach (var file in Directory.GetFiles(directory, searchPattern)) { try { var assembly = Assembly.LoadFile(file); if (assembly.FullName.StartsWith("Microsoft.") || assembly.FullName.StartsWith("System.")) { continue; } var assemblyCatalog = new AssemblyCatalog(assembly); catalog.Catalogs.Add(assemblyCatalog); } catch (Exception ex) { Trace.TraceError(ex.Message); } } var container = new CompositionContainer(catalog); container.ComposeParts(fixer); } }
private static void SnapshotExchangeRates(DateTime fromDate, DateTime untilDate) { using (var currencyMarket = new CurrencyMarketContext()) { DateTime currDate = fromDate; while (currDate <= untilDate) { Console.WriteLine("Snapshotting exchange rates in: " + currDate.ToString("dd/MM/yyyy")); foreach (var currExchangeRate in Fixer.GetAllExchangeRates(currDate)) { Currency sourceCurrency = currencyMarket.FindOrCreateCurrency(currExchangeRate.SourceCurrency); Currency targetCurrency = currencyMarket.FindOrCreateCurrency(currExchangeRate.TargetCurrency); currencyMarket.ExchangeRates.Add(new ExchangeRate() { SourceCurrency = sourceCurrency, TargetCurrency = targetCurrency, Rate = currExchangeRate.Rate, Date = currDate }); } currDate = currDate.AddDays(1); currencyMarket.SaveChanges(); } } }
public object ToBLO() { var config = new MapperConfiguration(cfg => { cfg.AddProfile <GetResolvedCasesResultMapProfile>(); }); IMapper mapper = new Mapper(config); var blo = mapper.Map <EmpGetNextResolvedCaseNbrsRespBLO>(this); Fixer.TryFixInvalidWithGetCaseDetails(blo.CaseList); Fixer.RemoveInvalidFromCollection(blo.CaseList); //blo.CaseList = blo.CaseList.Where(x => Fixer.IsValid(x)).ToArray(); blo.NumberOfCases = blo.CaseList.Count(); if (this.CaseList.Count() > blo.CaseList.Count()) { int count = this.CaseList.Count() - blo.CaseList.Count(); string msg = string.Format("Mapping was missed for {0} cases; RawRespObject= ", count); Log_Error.AddError("Map<EmpGetNextResolvedCaseNbrsRespBLO>", "EVerifyService", msg + CustomTextMessageEncoder.LastResponceObjectRawString, true, false, "WP", string.Empty, "", "EVerify"); } blo.DTO = this; return(blo); }
public void Rate_Date_Properties_Contain_Data() { var rate1 = Fixer.Rate(Symbols.GBP, Symbols.EUR, new DateTime(2016, 10, 19)); var rate2 = Fixer.Rate(Symbols.GBP, Symbols.EUR, new DateTime(2016, 10, 18)); Assert.AreNotEqual(rate1.Rate, rate2.Rate); }
protected override async Task <Document> GetChangedSuppressionDocumentAsync(CancellationToken cancellationToken) { var suppressionsDoc = await GetOrCreateSuppressionsDocumentAsync(cancellationToken).ConfigureAwait(false); var services = suppressionsDoc.Project.Solution.Workspace.Services; var suppressionsRoot = await suppressionsDoc.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); var addImportsService = suppressionsDoc.GetRequiredLanguageService <IAddImportsService>(); var options = await SyntaxFormattingOptions.FromDocumentAsync(suppressionsDoc, cancellationToken).ConfigureAwait(false); foreach (var(targetSymbol, diagnostics) in _diagnosticsBySymbol) { foreach (var diagnostic in diagnostics) { Contract.ThrowIfFalse(!diagnostic.IsSuppressed); suppressionsRoot = Fixer.AddGlobalSuppressMessageAttribute( suppressionsRoot, targetSymbol, _suppressMessageAttribute, diagnostic, services, options, addImportsService, cancellationToken); } } var result = suppressionsDoc.WithSyntaxRoot(suppressionsRoot); var final = await CleanupDocumentAsync(result, cancellationToken).ConfigureAwait(false); return(final); }
private ERSnapshotsTracker SnapshotExchangeRates(DateTime fromDate, DateTime untilDate) { ERSnapshotsTracker tracker = new ERSnapshotsTracker(); DateTime currDate = fromDate; while (currDate <= untilDate) { if (!currencyMarket.ContainsExchangeRatesIn(currDate)) { logger.LogInformation("Snapshotting exchange rates in: " + currDate.ToString("dd/MM/yyyy")); foreach (var currExchangeRate in Fixer.GetAllExchangeRates(currDate)) { Currency sourceCurrency = currencyMarket.FindOrCreateCurrency(currExchangeRate.SourceCurrency); Currency targetCurrency = currencyMarket.FindOrCreateCurrency(currExchangeRate.TargetCurrency); currencyMarket.ExchangeRates.Add(new ExchangeRate() { SourceCurrency = sourceCurrency, TargetCurrency = targetCurrency, Rate = currExchangeRate.Rate, Date = currDate }); } tracker.ExchangeRates += currencyMarket.ExchangeRates.Local.Count; currencyMarket.SaveChanges(); tracker.Dates++; } else { logger.LogInformation("Already contained the exchange rates in: " + currDate.ToString("dd/MM/yyyy") + " [Skipping]"); } currDate = currDate.AddDays(1); } return(tracker); }
public void Rates_For_Previous_Dates_Contain_Different_Data() { var rate1 = Fixer.Rate(Symbols.GBP, Symbols.EUR, new DateTime(2016, 10, 19)); var rate2 = Fixer.Rate(Symbols.GBP, Symbols.EUR, new DateTime(2016, 10, 18)); Assert.AreNotEqual(rate1.Rate, rate2.Rate); Assert.AreNotEqual(rate1.Date, rate2.Date); }
public async Task <SyntaxNode> GetAttributeToRemoveAsync(CancellationToken cancellationToken) { var attributeNode = await _attribute.ApplicationSyntaxReference.GetSyntaxAsync(cancellationToken).ConfigureAwait(false); return(Fixer.IsSingleAttributeInAttributeList(attributeNode) ? attributeNode.Parent : attributeNode); }
public Transaction Exchange(Transaction trans) { ExchangeRate excRate = Fixer.Rate(trans.Source_Currency, trans.Destination_Currency); trans.FX_Rate = excRate.Rate.ToString("0.00"); trans.Destination_Amount = Fixer.Convert(trans.Source_Currency, trans.Destination_Currency, Double.Parse(trans.Source_Amount)).ToString("0.00"); return(trans); }
public void FixThosePipes_t3() { CollectionAssert.AreEqual(new List <int> { 6, 7, 8, 9 }, Fixer.PipeFix(new List <int> { 6, 9 })); }
public void FixThosePipes_t2() { CollectionAssert.AreEqual(new List <int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }, Fixer.PipeFix(new List <int> { 1, 2, 3, 12 })); }
public void FixThosePipes_t1() { CollectionAssert.AreEqual(new List <int> { 1, 2, 3, 4, 5, 6, 7, 8, 9 }, Fixer.PipeFix(new List <int> { 1, 2, 3, 5, 6, 8, 9 })); }
public void Rate_Properties_Contain_Data() { var rate = Fixer.Rate(Symbols.GBP, Symbols.EUR); Assert.AreNotEqual(rate.From, ""); Assert.AreNotEqual(rate.To, ""); Assert.AreNotEqual(rate.Rate, 0); }
private void Awake() { var vals = this.GetComponentsInChildren <Inspector>(); this.firstInspector = vals[0]; this.secondInspector = vals[1]; this.fixer = this.GetComponentInChildren <Fixer>(); }
public Entry(InclusiveScope scope, Style.ConfigStyle configStyle, Checker check, Fixer fix) { this.scope = scope; this.configStyle = configStyle; this.check = check; this.fix = fix; indent = scope == InclusiveScope.HDRPAsset || scope == InclusiveScope.XRManagement ? 1 : 0; }
public string valuta() { if (isNumeric == true) { exchangeResult = Fixer.Convert(curentCurrency, newCurrency, Convert.ToDouble(txtDeposit.Text)); } return($"{Math.Round(exchangeResult, 4)} {newCurrency}"); }
public object Adapt(Fixer fixer) { return new FixAppBuilder(fixer); }
public FixAppBuilder(Fixer fixer) { _fixer = fixer; }