Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="signatoryModel"></param>
        /// <returns></returns>
        public async Task <SignatoryModel> CreateOrUpdate(SignatoryModel signatoryModel)
        {
            if (signatoryModel.Id == Guid.Empty)
            {
                signatoryModel.Id = Guid.NewGuid();
            }
            var signatoryDb = await _signatorRepository.FindBy(s => s.Id == signatoryModel.Id).ConfigureAwait(false);

            if (signatoryDb == null)
            {
                var signatory = AutoMapper.Mapper.Map <Signatory>(signatoryModel);
                _signatorRepository.Create(signatory);
                _signatorRepository.Save(true, false, signatoryModel.Id);
            }
            else
            {
                AutoMapper.Mapper.Map(signatoryModel, signatoryDb);
                _signatorRepository.Update(signatoryDb);
                _signatorRepository.Save(true, false, signatoryModel.Id);
            }

            return(signatoryModel);
        }
Exemplo n.º 2
0
        /// <inheritdoc />
        /// <summary>
        /// </summary>
        /// <param name="benChainContextModel"></param>
        /// <returns></returns>
        public async Task <BenChainContextModel> UpdateBenChainStatus(BenChainContextModel benChainContextModel)
        {
            //First to
            var signatorDb = (await _signatorRepository.GetAllWhere(c => c.Id == benChainContextModel.ContextId && benChainContextModel.Status == 0).ConfigureAwait(false)).OrderBy(c => c.OrderId).FirstOrDefault();

            if (signatorDb == null)
            {
                return(benChainContextModel);
            }

            signatorDb.BenChainABI        = benChainContextModel.ABI;
            signatorDb.BenChainBytescode  = benChainContextModel.Bytescode;
            signatorDb.BenChainContractId = benChainContextModel.ContractId;
            _signatorRepository.Update(signatorDb);
            _signatorRepository.Save(false, false, signatorDb.Id);

            return(benChainContextModel);
        }