コード例 #1
0
        public IActionResult UpdateManagerHistoryIpfsHash([FromBody] ManagerHistoryIpfsHash data)
        {
            var errors = brokerValidator.ValidateUpdateManagerHistoryIpfsHash(CurrentUser, data);

            if (errors.Any())
            {
                return(BadRequest(ErrorResult.GetResult(errors, ErrorCodes.ValidationError)));
            }

            var result = trustManagementService.UpdateManagerHistoryIpfsHash(data);

            if (!result.IsSuccess)
            {
                return(BadRequest(ErrorResult.GetResult(result)));
            }

            return(Ok());
        }
コード例 #2
0
        public OperationResult UpdateManagerHistoryIpfsHash(ManagerHistoryIpfsHash data)
        {
            return(InvokeOperations.InvokeOperation(() =>
            {
                foreach (var manager in data.ManagersHashes)
                {
                    var managerData = context.ManagersAccounts.FirstOrDefault(x => x.Id == manager.ManagerId);
                    if (managerData == null)
                    {
                        continue;
                    }

                    managerData.TradeIpfsHash = manager.IpfsHash;
                }

                if (data.ManagersHashes.Any())
                {
                    context.SaveChanges();
                }
            }));
        }
コード例 #3
0
        public List <string> ValidateUpdateManagerHistoryIpfsHash(ApplicationUser user, ManagerHistoryIpfsHash data)
        {
            var result = new List <string>();

            var ids = data.ManagersHashes.Select(x => x.ManagerId).Distinct().ToList();
            var mangerAccountCount = context.ManagersAccounts.Count(x => ids.Contains(x.Id));

            if (mangerAccountCount != ids.Count)
            {
                result.Add("Manager account does not exist");
            }

            return(result);
        }