Esempio n. 1
0
        public async Task <ActionResult> Edit(AssetPairEditModel model)
        {
            if (string.IsNullOrEmpty(model.Id))
            {
                return(this.JsonFailResult(Phrases.FieldShouldNotBeEmpty, "#id"));
            }

            if (string.IsNullOrEmpty(model.EditId) || model.EditId != model.Id)
            {
                if (await _assetPairsRepository.GetAsync(model.Id) != null)
                {
                    return(this.JsonFailResult(Phrases.AssetPairWithSameIdExists, "#id"));
                }
            }

            if (string.IsNullOrEmpty(model.BaseAssetId))
            {
                return(this.JsonFailResult(Phrases.FieldShouldNotBeEmpty, "#baseAssetId"));
            }

            if (string.IsNullOrEmpty(model.QuotingAssetId))
            {
                return(this.JsonFailResult(Phrases.FieldShouldNotBeEmpty, "#quotingAssetId"));
            }

            if (model.Accuracy <= 0)
            {
                return(this.JsonFailResult(Phrases.PleaseTypeAccuracy, "#accuracy"));
            }


            if (string.IsNullOrEmpty(model.EditId))
            {
                await _assetPairsRepository.AddAsync(model);
            }
            else
            {
                await _assetPairsRepository.EditAsync(model.EditId, model);
            }

            return(this.JsonRequestResult(WebSiteConstants.PersonalAreaDiv, Url.Action("Index")));
        }
Esempio n. 2
0
        private static void PopulateAssetPairsRepository(this IAssetPairsRepository assetsRepository)
        {
            assetsRepository.AddAsync(new AssetPair
            {
                Id             = "AUDNZD",
                BaseAssetId    = "AUD",
                QuotingAssetId = "NZD",
                Accuracy       = 5
            });



            assetsRepository.AddAsync(new AssetPair
            {
                Id             = "AUDCAD",
                BaseAssetId    = "AUD",
                QuotingAssetId = "CAD",
                Accuracy       = 5
            });

            assetsRepository.AddAsync(new AssetPair
            {
                Id             = "AUDCHF",
                BaseAssetId    = "AUD",
                QuotingAssetId = "CHF",
                Accuracy       = 5
            });

            assetsRepository.AddAsync(new AssetPair
            {
                Id             = "AUDJPY",
                BaseAssetId    = "AUD",
                QuotingAssetId = "JPY",
                Accuracy       = 3
            });


            assetsRepository.AddAsync(new AssetPair
            {
                Id             = "AUDUSD",
                BaseAssetId    = "AUD",
                QuotingAssetId = "USD",
                Accuracy       = 5
            });


            assetsRepository.AddAsync(new AssetPair
            {
                Id             = "CADCHF",
                BaseAssetId    = "CAD",
                QuotingAssetId = "CHF",
                Accuracy       = 5
            });

            assetsRepository.AddAsync(new AssetPair
            {
                Id             = "CADJPY",
                BaseAssetId    = "CAD",
                QuotingAssetId = "JPY",
                Accuracy       = 3
            });


            assetsRepository.AddAsync(new AssetPair
            {
                Id             = "CHFJPY",
                BaseAssetId    = "CHF",
                QuotingAssetId = "JPY",
                Accuracy       = 3
            });


            assetsRepository.AddAsync(new AssetPair
            {
                Id             = "EURAUD",
                BaseAssetId    = "EUR",
                QuotingAssetId = "AUD",
                Accuracy       = 5
            });

            assetsRepository.AddAsync(new AssetPair
            {
                Id             = "EURCAD",
                BaseAssetId    = "EUR",
                QuotingAssetId = "CAD",
                Accuracy       = 5
            });

            assetsRepository.AddAsync(new AssetPair
            {
                Id             = "EURCHF",
                BaseAssetId    = "EUR",
                QuotingAssetId = "CHF",
                Accuracy       = 5
            });

            assetsRepository.AddAsync(new AssetPair
            {
                Id             = "EURGBP",
                BaseAssetId    = "EUR",
                QuotingAssetId = "GBP",
                Accuracy       = 5
            });

            assetsRepository.AddAsync(new AssetPair
            {
                Id             = "EURJPY",
                BaseAssetId    = "EUR",
                QuotingAssetId = "JPY",
                Accuracy       = 3
            });

            assetsRepository.AddAsync(new AssetPair
            {
                Id             = "EURNZD",
                BaseAssetId    = "EUR",
                QuotingAssetId = "NZD",
                Accuracy       = 5
            });

            assetsRepository.AddAsync(new AssetPair
            {
                Id             = "EURUSD",
                BaseAssetId    = "EUR",
                QuotingAssetId = "USD",
                Accuracy       = 5
            });


            assetsRepository.AddAsync(new AssetPair
            {
                Id             = "GBPAUD",
                BaseAssetId    = "GBP",
                QuotingAssetId = "AUD",
                Accuracy       = 5
            });

            assetsRepository.AddAsync(new AssetPair
            {
                Id             = "GBPCAD",
                BaseAssetId    = "GBP",
                QuotingAssetId = "CAD",
                Accuracy       = 5
            });

            assetsRepository.AddAsync(new AssetPair
            {
                Id             = "GBPCHF",
                BaseAssetId    = "GBP",
                QuotingAssetId = "CHF",
                Accuracy       = 5
            });

            assetsRepository.AddAsync(new AssetPair
            {
                Id             = "GBPJPY",
                BaseAssetId    = "GBP",
                QuotingAssetId = "JPY",
                Accuracy       = 3
            });

            assetsRepository.AddAsync(new AssetPair
            {
                Id             = "GBPNZD",
                BaseAssetId    = "GBP",
                QuotingAssetId = "NZD",
                Accuracy       = 5
            });

            assetsRepository.AddAsync(new AssetPair
            {
                Id             = "GBPUSD",
                BaseAssetId    = "GBP",
                QuotingAssetId = "USD",
                Accuracy       = 5
            });


            assetsRepository.AddAsync(new AssetPair
            {
                Id             = "NZDCAD",
                BaseAssetId    = "NZD",
                QuotingAssetId = "CAD",
                Accuracy       = 5
            });

            assetsRepository.AddAsync(new AssetPair
            {
                Id             = "NZDCHF",
                BaseAssetId    = "NZD",
                QuotingAssetId = "CHF",
                Accuracy       = 5
            });

            assetsRepository.AddAsync(new AssetPair
            {
                Id             = "NZDJPY",
                BaseAssetId    = "NZD",
                QuotingAssetId = "JPY",
                Accuracy       = 3
            });

            assetsRepository.AddAsync(new AssetPair
            {
                Id             = "NZDUSD",
                BaseAssetId    = "NZD",
                QuotingAssetId = "USD",
                Accuracy       = 5
            });


            assetsRepository.AddAsync(new AssetPair
            {
                Id             = "USDCAD",
                BaseAssetId    = "USD",
                QuotingAssetId = "CAD",
                Accuracy       = 5
            });

            assetsRepository.AddAsync(new AssetPair
            {
                Id             = "USDCHF",
                BaseAssetId    = "USD",
                QuotingAssetId = "CHF",
                Accuracy       = 5
            });

            assetsRepository.AddAsync(new AssetPair
            {
                Id             = "USDJPY",
                BaseAssetId    = "USD",
                QuotingAssetId = "JPY",
                Accuracy       = 3
            });
        }