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")));
        }