Пример #1
0
 private CurrencyInfo(CurrencyId id, string sign, string sign2 = null, bool signPost = false, string url = null)
 {
     CurrencyId  = id;
     Sign        = sign;
     Sign2       = sign2 ?? sign;
     SignPostfix = signPost;
 }
Пример #2
0
        public override int GetHashCode()
        {
            int hashCode = 1803674884;

            hashCode = hashCode * -1521134295 + Id.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Name);

            hashCode = hashCode * -1521134295 + IsIntermediate.GetHashCode();
            hashCode = hashCode * -1521134295 + IsDanger.GetHashCode();
            hashCode = hashCode * -1521134295 + IsProduction.GetHashCode();
            hashCode = hashCode * -1521134295 + IsActive.GetHashCode();
            hashCode = hashCode * -1521134295 + IntermediateNrD.GetHashCode();
            hashCode = hashCode * -1521134295 + ClpSignalWordId.GetHashCode();
            hashCode = hashCode * -1521134295 + ClpMsdsId.GetHashCode();
            hashCode = hashCode * -1521134295 + FunctionId.GetHashCode();
            hashCode = hashCode * -1521134295 + Price.GetHashCode();
            hashCode = hashCode * -1521134295 + CurrencyId.GetHashCode();
            hashCode = hashCode * -1521134295 + UnitId.GetHashCode();
            hashCode = hashCode * -1521134295 + Density.GetHashCode();
            hashCode = hashCode * -1521134295 + Solids.GetHashCode();
            hashCode = hashCode * -1521134295 + Ash450.GetHashCode();
            hashCode = hashCode * -1521134295 + VOC.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Remarks);

            hashCode = hashCode * -1521134295 + LoginId.GetHashCode();
            hashCode = hashCode * -1521134295 + DateCreated.GetHashCode();
            hashCode = hashCode * -1521134295 + DateUpdated.GetHashCode();
            return(hashCode);
        }
Пример #3
0
        public void Delete_ExistingId_DeletesAndReturnsNoContentResultWithId()
        {
            // Arrange
            // create fictional currency
            CurrencyId id = null;

            this.SetupSession.DoInTransaction(() =>
            {
                var currency = new Currency("WAT", "Wat Dynero");
                this.SetupSession.Save(currency);
                id = currency.Id;
            });

            // Act
            var response = this.HttpClient.DeleteAsync($"api/currencies/{id}").Result;

            // Assert
            Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.NoContent));

            var instanceId = response.Headers.GetValues("X-Deleted-Instance-Id").Single();

            Assert.That(instanceId, Is.EqualTo(id.ToString()));

            var deletedCurrency = this.AssertSession
                                  .Query <Currency>()
                                  .SingleOrDefault(x => x.Id == id);

            Assert.That(deletedCurrency, Is.Null);
        }
Пример #4
0
        public IActionResult UpdateCurrency([FromRoute] CurrencyId id, UpdateCurrencyCommand command)
        {
            command.Id = id;

            try
            {
                _commandDispatcher.Dispatch(command);

                var query = new GetCurrencyQuery
                {
                    Id = id,
                };

                _queryRunner.Run(query);

                var queryResult = query.GetResult();
                var url         = this.Url.Action("GetCurrency", "GetCurrency", new { id });

                return(this.Ok(queryResult));
            }
            catch (CurrencyNotFoundException ex)
            {
                return(this.NotFoundError(ex));
            }
            catch (CodeAlreadyExistsException ex)
            {
                return(this.ConflictError(ex));
            }
        }
Пример #5
0
        public override int GetHashCode()
        {
            int hashCode = -771160272;

            hashCode = hashCode * -1521134295 + CurrencyId.GetHashCode();
            hashCode = hashCode * -1521134295 + Value.GetHashCode();
            return(hashCode);
        }
        public Currency GetById(CurrencyId id)
        {
            if (id == null)
            {
                throw new ArgumentNullException(nameof(id));
            }

            return(_session.Query <Currency>().SingleOrDefault(x => x.Id == id));
        }
Пример #7
0
 public InstrumentViewItem(Instrument instrument)
     : base(new string[5])
 {
     this.Instrument       = instrument;
     this.SubItems[0].Text = instrument.Symbol;
     this.SubItems[1].Text = instrument.Type.ToString();
     this.SubItems[2].Text = instrument.Exchange;
     this.SubItems[3].Text = CurrencyId.GetName(instrument.CurrencyId);
     this.SubItems[4].Text = instrument.Maturity == DateTime.MinValue ? string.Empty : instrument.Maturity.ToShortDateString();
 }
Пример #8
0
        public Asset(AssetId32Bits assetId, string symbol, string name, string shortName, CurrencyId currency)
        {
            AssetId   = assetId;
            Symbol    = symbol;
            Name      = name;
            ShortName = shortName;
            Currency  = currency;

            SqTicker = AssetHelper.gAssetTypeCode[AssetId.AssetTypeID] + "/" + Symbol;
        }
Пример #9
0
 internal void AppendToQueryParameters(Dictionary <string, string> queryParameters)
 {
     queryParameters.Add(Parameters.BuyRateNqt, BuyRate.Nqt.ToString());
     queryParameters.Add(Parameters.Currency, CurrencyId.ToString());
     queryParameters.Add(Parameters.ExpirationHeight, ExpirationHeight.ToString());
     queryParameters.Add(Parameters.InitialBuySupply, InitialBuySupply.ToString());
     queryParameters.Add(Parameters.InitialSellSupply, InitialSellSupply.ToString());
     queryParameters.Add(Parameters.SellRateNqt, SellRate.Nqt.ToString());
     queryParameters.Add(Parameters.TotalBuyLimit, TotalBuyLimit.ToString());
     queryParameters.Add(Parameters.TotalSellLimit, TotalSellLimit.ToString());
 }
 public CurrencyCreatedDomainEvent(
     CurrencyId id,
     string code,
     string name,
     string correlationId,
     DateTime occurredAt)
 {
     this.Id            = id ?? throw new ArgumentNullException(nameof(id));
     this.Code          = code ?? throw new ArgumentNullException(nameof(code));
     this.Name          = name ?? throw new ArgumentNullException(nameof(name));
     this.CorrelationId = correlationId;
     this.OccurredAt    = occurredAt;
 }
Пример #11
0
        /// <inheritdocs />
        public override NameValueCollection GetParameters()
        {
            var retval = new NameValueCollection
            {
                { "startDate", StartDate.ToString("yyyy-MM-dd") },
                { "endDate", EndDate.ToString("yyyy-MM-dd") },
                { "staffels", Staffels.ToString() },
                { "CurrencyId", CurrencyId?.ToString() },
            };

            retval.Add(GenerateFiltersNameValueCollection());
            retval.Add(GenerateGroupByClause());
            return(retval);
        }
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            List <ValidationResult> validationResult = new List <ValidationResult>();

            if (string.IsNullOrWhiteSpace(this.BankName))
            {
                validationResult.Add(new ValidationResult("Bank Name is required", new List <string> {
                    "BankName"
                }));
            }

            if (string.IsNullOrWhiteSpace(this.AccountName))
            {
                validationResult.Add(new ValidationResult("Account Name is required", new List <string> {
                    "AccountName"
                }));
            }

            if (string.IsNullOrWhiteSpace(this.AccountNumber))
            {
                validationResult.Add(new ValidationResult("Account Number is required", new List <string> {
                    "AccountNumber"
                }));
            }

            if (CurrencyId.Equals(null))
            {
                validationResult.Add(new ValidationResult("Currency is required", new List <string> {
                    "CurrencyID"
                }));
            }

            if (validationResult.Count.Equals(0))
            {
                /* Service Validation */
                AccountBankService service = (AccountBankService)validationContext.GetService(typeof(AccountBankService));

                if (service.DbContext.Set <AccountBank>().Count(r => r._IsDeleted.Equals(false) && r.Id != this.Id && r.BankName.Equals(this.BankName) && r.AccountNumber.Equals(this.AccountNumber)) > 0) /* Unique */
                {
                    validationResult.Add(new ValidationResult("Bank Name and Account Number already exists", new List <string> {
                        "BankName"
                    }));
                    validationResult.Add(new ValidationResult("Bank Name and Account Number already exists", new List <string> {
                        "AccountNumber"
                    }));
                }
            }

            return(validationResult);
        }
Пример #13
0
        public void Delete_NonExistingId_ReturnsNotFoundResult()
        {
            // Arrange
            var nonExistingCurrencyId = new CurrencyId("eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee");

            // Act
            var response = this.HttpClient.DeleteAsync($"api/currencies/{nonExistingCurrencyId}").Result;

            // Assert
            Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.NotFound));
            var error = response.ReadAsError();

            Assert.That(error.Code, Is.EqualTo(typeof(CurrencyNotFoundException).FullName));
            Assert.That(error.Message, Is.EqualTo("Currency not found."));
        }
Пример #14
0
        public static CurrencyInfo Get(CurrencyId currencyId)
        {
            switch (currencyId)
            {
            case CurrencyId.USD:
                return(kUSD);

            case CurrencyId.EUR:
                return(kEUR);

            case CurrencyId.JPY:
                return(kJPY);

            case CurrencyId.GBP:
                return(kGBP);

            case CurrencyId.AUD:
                return(kAUD);

            case CurrencyId.CAD:
                return(kCAD);

            case CurrencyId.CHF:
                return(kCHF);

            case CurrencyId.CNY:
                return(kCNY);

            case CurrencyId.SEK:
                return(kSEK);

            case CurrencyId.NZD:
                return(kNZD);

            case CurrencyId.MXN:
                return(kMXN);

            case CurrencyId.SGD:
                return(kSGD);

            // ...

            case CurrencyId.BTC:
                return(kBTC);
            }

            return(kUNK);
        }
        public bool Delete(CurrencyId id)
        {
            if (id == null)
            {
                throw new ArgumentNullException(nameof(id));
            }

            var currency = _session.Query <Currency>().SingleOrDefault(x => x.Id == id);

            if (currency != null)
            {
                _session.Delete(currency);
            }

            return(currency != null);
        }
Пример #16
0
        /// <inheritdoc />
        public override int GetHashCode()
        {
            unchecked
            {
                var hashCode = (int)Action;
                hashCode = (hashCode * 397) ^ AppId;
                hashCode = (hashCode * 397) ^ AssetId.GetHashCode();
                hashCode = (hashCode * 397) ^ CurrencyId.GetHashCode();
                hashCode = (hashCode * 397) ^ ContextId.GetHashCode();
                hashCode = (hashCode * 397) ^ SteamId.GetHashCode();
                hashCode = (hashCode * 397) ^ (Text != null ? Text.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ Timestamp.GetHashCode();

                return(hashCode);
            }
        }
Пример #17
0
        public void UpdateGUI()
        {
            this.portfolio = Framework.Current.PortfolioManager[this.name];
            if (this.portfolio == null)
            {
                return;
            }
            this.ltvPortfolio.BeginUpdate();
            string format = "F2";

            this.ltvPortfolio.Items[0].SubItems[0].Text = CurrencyId.GetName(this.portfolio.Account.CurrencyId);
            this.ltvPortfolio.Items[0].SubItems[1].Text = this.portfolio.AccountValue.ToString(format);
            this.ltvPortfolio.Items[0].SubItems[2].Text = this.portfolio.PositionValue.ToString(format);
            this.ltvPortfolio.Items[0].SubItems[3].Text = this.portfolio.Value.ToString(format);
            this.ltvPortfolio.EndUpdate();
            this.ltvTransactions.VirtualListSize = this.TransactionsViewItems.Count;
        }
        public IActionResult DeleteCurrency([FromRoute] CurrencyId id)
        {
            var command = new DeleteCurrencyCommand
            {
                Id = id,
            };

            try
            {
                _commandDispatcher.Dispatch(command);

                return(this.DeletedNoContent(id.ToString()));
            }
            catch (CurrencyNotFoundException ex)
            {
                return(this.NotFoundError(ex));
            }
        }
Пример #19
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (CurrencyId.Length != 0)
            {
                hash ^= CurrencyId.GetHashCode();
            }
            if (Amount != 0L)
            {
                hash ^= Amount.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Пример #20
0
        public void UpdateCurrency_InvalidRequest_ReturnsValidationErrorResponse()
        {
            // Arrange
            var id      = new CurrencyId("59f103f7-c20e-4c97-ac39-17be6adfd3e1");
            var command = new UpdateCurrencyCommand(); // all nulls

            // Act
            var response = this.HttpClient.PutAsJsonAsync($"api/currencies/{id}", command).Result;

            // Assert
            Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));

            var validationError = response.ReadAsValidationError();

            validationError
            .ShouldHaveFailureNumber(2)
            .ShouldContainFailure("code", "NotEmptyValidator", "'Code' must not be empty.")
            .ShouldContainFailure("name", "NotEmptyValidator", "'Name' must not be empty.");
        }
        public IActionResult GetCurrency([FromQuery] CurrencyId id = null, [FromQuery] string code = null)
        {
            var query = new GetCurrencyQuery
            {
                Id   = id,
                Code = code,
            };

            try
            {
                _queryRunner.Run(query);
                var result = query.GetResult();
                return(this.Ok(result));
            }
            catch (CurrencyNotFoundException ex)
            {
                return(this.NotFoundError(ex));
            }
            catch (ValidationException ex)
            {
                return(this.ValidationError(ex));
            }
        }
Пример #22
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Nickname != null)
         {
             hashCode = hashCode * 59 + Nickname.GetHashCode();
         }
         if (CurrencyId != null)
         {
             hashCode = hashCode * 59 + CurrencyId.GetHashCode();
         }
         if (AccountHolder != null)
         {
             hashCode = hashCode * 59 + AccountHolder.GetHashCode();
         }
         if (AccountNumber != null)
         {
             hashCode = hashCode * 59 + AccountNumber.GetHashCode();
         }
         if (Iban != null)
         {
             hashCode = hashCode * 59 + Iban.GetHashCode();
         }
         if (BankName != null)
         {
             hashCode = hashCode * 59 + BankName.GetHashCode();
         }
         if (SortCode != null)
         {
             hashCode = hashCode * 59 + SortCode.GetHashCode();
         }
         if (RoutingNumber != null)
         {
             hashCode = hashCode * 59 + RoutingNumber.GetHashCode();
         }
         if (SwiftBic != null)
         {
             hashCode = hashCode * 59 + SwiftBic.GetHashCode();
         }
         if (IfscCode != null)
         {
             hashCode = hashCode * 59 + IfscCode.GetHashCode();
         }
         if (RoutingCode != null)
         {
             hashCode = hashCode * 59 + RoutingCode.GetHashCode();
         }
         if (UserAddressId != null)
         {
             hashCode = hashCode * 59 + UserAddressId.GetHashCode();
         }
         if (BankAddress != null)
         {
             hashCode = hashCode * 59 + BankAddress.GetHashCode();
         }
         return(hashCode);
     }
 }
Пример #23
0
        public BrokerNav(AssetId32Bits assetId, string symbol, string name, string shortName, CurrencyId currency, User user, DateTime histStartDate, List <BrokerNav> aggregateNavChildren)
            : base(assetId, symbol, name, shortName, currency)
        {
            User = user;
            ExpectedHistoryStartDateLoc = histStartDate;
            AggregateNavChildren        = aggregateNavChildren;

            if (GatewayExtensions.NavSymbol2GatewayId.TryGetValue(Symbol, out GatewayId gatewayId))
            {
                GatewayId = gatewayId;
            }
        }
Пример #24
0
 public override string ToString()
 {
     return(string.Format("AccountId={0}, CurrencyId={1}, Balance={2}, Necessary={3}, InterestPLNotValued={4}, StoragePLNotValued={5}, TradePLNotValued={6}, InterestPLFloat={7}, StoragePLFloat={8}, TradePLFloat={9}, UnclearAmount={10}, PedgeAmount={11}, FrozenFund={12}",
                          AccountId, CurrencyId == null ? "NULL" : CurrencyId.ToString(), Balance, Necessary, InterestPLNotValued, StoragePLNotValued, TradePLNotValued, InterestPLFloat, StoragePLFloat, TradePLFloat, UnclearAmount, PedgeAmount, FrozenFund));
 }
Пример #25
0
 public CompanyData(CompanyId companyId, string name, CurrencyId baseCurrencyId)
 {
     CompanyId      = companyId;
     Name           = name;
     BaseCurrencyId = baseCurrencyId;
 }
Пример #26
0
        /// <summary>
        /// Returns true if BankInfo instances are equal
        /// </summary>
        /// <param name="other">Instance of BankInfo to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(BankInfo other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Nickname == other.Nickname ||
                     Nickname != null &&
                     Nickname.Equals(other.Nickname)
                     ) &&
                 (
                     CurrencyId == other.CurrencyId ||
                     CurrencyId != null &&
                     CurrencyId.Equals(other.CurrencyId)
                 ) &&
                 (
                     AccountHolder == other.AccountHolder ||
                     AccountHolder != null &&
                     AccountHolder.Equals(other.AccountHolder)
                 ) &&
                 (
                     AccountNumber == other.AccountNumber ||
                     AccountNumber != null &&
                     AccountNumber.Equals(other.AccountNumber)
                 ) &&
                 (
                     Iban == other.Iban ||
                     Iban != null &&
                     Iban.Equals(other.Iban)
                 ) &&
                 (
                     BankName == other.BankName ||
                     BankName != null &&
                     BankName.Equals(other.BankName)
                 ) &&
                 (
                     SortCode == other.SortCode ||
                     SortCode != null &&
                     SortCode.Equals(other.SortCode)
                 ) &&
                 (
                     RoutingNumber == other.RoutingNumber ||
                     RoutingNumber != null &&
                     RoutingNumber.Equals(other.RoutingNumber)
                 ) &&
                 (
                     SwiftBic == other.SwiftBic ||
                     SwiftBic != null &&
                     SwiftBic.Equals(other.SwiftBic)
                 ) &&
                 (
                     IfscCode == other.IfscCode ||
                     IfscCode != null &&
                     IfscCode.Equals(other.IfscCode)
                 ) &&
                 (
                     RoutingCode == other.RoutingCode ||
                     RoutingCode != null &&
                     RoutingCode.Equals(other.RoutingCode)
                 ) &&
                 (
                     UserAddressId == other.UserAddressId ||
                     UserAddressId != null &&
                     UserAddressId.Equals(other.UserAddressId)
                 ) &&
                 (
                     BankAddress == other.BankAddress ||
                     BankAddress != null &&
                     BankAddress.Equals(other.BankAddress)
                 ));
        }