Пример #1
0
        public IResult <ICustomerContractDetailReturn> GetCustomerContract(string customerContractKey)
        {
            if (customerContractKey == null)
            {
                throw new ArgumentNullException("customerContractKey");
            }

            var contractKeyResult = KeyParserHelper.ParseResult <IContractKey>(customerContractKey);

            if (!contractKeyResult.Success)
            {
                return(contractKeyResult.ConvertTo <ICustomerContractDetailReturn>());
            }
            var contractKey = new ContractKey(contractKeyResult.ResultingObject);

            var select         = ContractProjectors.SelectDetail();
            var contractDetail = _inventoryShipmentOrderUnitOfWork.ContractRepository.All()
                                 .Where(contractKey.FindByPredicate)
                                 .SplitSelect(select).FirstOrDefault();

            if (contractDetail == null)
            {
                return(new InvalidResult <ICustomerContractDetailReturn>(null, string.Format(UserMessages.CustomerContractNotFound, customerContractKey)));
            }

            return(new SuccessResult <ICustomerContractDetailReturn>(contractDetail));
        }
Пример #2
0
        public Com.DigitalAsset.Ledger.Api.V1.CreatedEvent ToProto()
        {
            var createdEvent = new Com.DigitalAsset.Ledger.Api.V1.CreatedEvent
            {
                ContractId      = ContractId,
                CreateArguments = Arguments.ToProtoRecord(),
                EventId         = EventId,
                TemplateId      = TemplateId.ToProto()
            };

            AgreementText.IfPresent(t => createdEvent.AgreementText = t);
            ContractKey.IfPresent(k => createdEvent.ContractKey     = k.ToProto());

            createdEvent.WitnessParties.AddRange(WitnessParties);
            createdEvent.Signatories.AddRange(Signatories);
            createdEvent.Observers.AddRange(Observers);

            return(createdEvent);
        }
Пример #3
0
        public IResult <IContractShipmentSummaryReturn> GetContractShipmentSummary(string contractKey)
        {
            var contractKeyResult = KeyParserHelper.ParseResult <IContractKey>(contractKey);

            if (!contractKeyResult.Success)
            {
                return(contractKeyResult.ConvertTo <IContractShipmentSummaryReturn>());
            }
            var key    = new ContractKey(contractKeyResult.ResultingObject);
            var select = ContractProjectors.SplitSelectShipmentSummary();

            var contract = _inventoryShipmentOrderUnitOfWork.ContractRepository
                           .All().Where(key.FindByPredicate)
                           .SplitSelect(select).FirstOrDefault();

            if (contract == null)
            {
                return(new InvalidResult <IContractShipmentSummaryReturn>(null, string.Format(UserMessages.CustomerContractNotFound, contractKey)));
            }

            return(new SuccessResult <IContractShipmentSummaryReturn>(contract));
        }
        internal IResult Execute(IContractKey contractKey, out int?contractId)
        {
            contractId = null;

            var key      = new ContractKey(contractKey);
            var contract = _salesUnitOfWork.ContractRepository
                           .FindByKey(key, c => c.ContractItems, c => c.Comments, c => c.Comments.Notes, c => c.ContractItems.Select(i => i.OrderItems));

            if (contract == null)
            {
                return(new InvalidResult(string.Format(UserMessages.CustomerContractNotFound, key.KeyValue)));
            }

            if (contract.ContractItems.SelectMany(i => i.OrderItems).Any())
            {
                return(new InvalidResult(string.Format(UserMessages.CustomerContractHasOrderItems, key.KeyValue)));
            }

            contractId = contract.ContractId;

            var deleteNotebookResult = new DeleteNotebookCommand(_salesUnitOfWork).Delete(contract.Comments);

            if (!deleteNotebookResult.Success)
            {
                return(deleteNotebookResult);
            }

            var contractItems = contract.ContractItems.ToList();

            foreach (var item in contractItems)
            {
                _salesUnitOfWork.ContractItemRepository.Remove(item);
            }
            _salesUnitOfWork.ContractRepository.Remove(contract);

            return(new SuccessResult());
        }
Пример #5
0
 /// <summary>
 /// 属性解析器
 /// </summary>
 /// <param name="contractKey">contractKey</param>
 private AnnotationsContractResolver(ContractKey contractKey)
     : this(contractKey.CamelCase, contractKey.FormatScope)
 {
 }
Пример #6
0
        /// <summary>
        /// 返回属性解析约定
        /// </summary>
        /// <param name="scope">序列化范围</param>
        /// <param name="camelCase">是否使用CamelCase</param>
        /// <exception cref="NotImplementedException"></exception>
        /// <returns></returns>
        public static AnnotationsContractResolver GetResolver(FormatScope scope, bool camelCase)
        {
            var key = new ContractKey(camelCase, scope);

            return(cache.GetOrAdd(key, k => new AnnotationsContractResolver(k)));
        }
 public static Contract GetContractForSynch(this IRepository <Contract> contractRepository, ContractKey contractKey)
 {
     return(contractRepository.FindByKey(contractKey, Expressions.SynchContractPaths));
 }
 public Com.Daml.Ledger.Api.V1.ExerciseByKeyCommand ToProto()
 {
     return(new Com.Daml.Ledger.Api.V1.ExerciseByKeyCommand {
         TemplateId = TemplateId.ToProto(), ContractKey = ContractKey.ToProto(), Choice = Choice, ChoiceArgument = ChoiceArgument.ToProto()
     });
 }