Inheritance: BaseEntity
        public PartyTypePair AddPartyTypePair(string title, PartyType alowedSource, PartyType alowedTarget, string description,
            PartyRelationshipType partyRelationshipType)
        {
            Contract.Requires(!string.IsNullOrEmpty(title));
            Contract.Requires(alowedSource != null && alowedSource.Id > 0);
            Contract.Requires(alowedTarget != null && alowedTarget.Id > 0);
            Contract.Ensures(Contract.Result<PartyTypePair>() != null && Contract.Result<PartyTypePair>().Id >= 0);

            var entity = new PartyTypePair()
            {
                AlowedSource = alowedSource,
                AlowedTarget = alowedTarget,
                Description = description,
                PartyRelationshipType = partyRelationshipType,
                Title = title
            };
            using (IUnitOfWork uow = this.GetUnitOfWork())
            {
                IRepository<PartyTypePair> repo = uow.GetRepository<PartyTypePair>();

                //Is it usefull?
                //var similarPartTypePair = repo.Get(item => item.AlowedSource == alowedSource && item.AlowedTarget == alowedTarget);
                //if (similarPartTypePair.Any())
                //    throw new Exception("Add party type pair failed.\r\nThere is already an entity with the same elements.");
                repo.Put(entity);
                uow.Commit();
            }
            return (entity);
        }
        /// <summary>
        /// Creating PartyRelationshipType
        /// because PartyRelationshipType should have PartyTypePairs,partyTypePair created in the same time of creating PartyRelationshipType
        /// </summary>
        /// <param name="title"></param>
        /// <param name="description"></param>
        /// <param name="indicatesHierarchy"></param>
        /// <param name="maxCardinality"></param>
        /// <param name="minCardinality"></param>
        /// <param name="partyTypePairAlowedSource"></param>
        /// <param name="partyTypePairAlowedTarget"></param>
        /// <param name="partyTypePairTitle"></param>
        /// <param name="partyTypePairDescription"></param>
        /// <returns></returns>
        public PartyRelationshipType Create(string title, string description, bool indicatesHierarchy, int maxCardinality,
            int minCardinality, PartyType partyTypePairAlowedSource, PartyType partyTypePairAlowedTarget,
            string partyTypePairTitle, string partyTypePairDescription)
        {
            Contract.Requires(!string.IsNullOrWhiteSpace(title) && !string.IsNullOrWhiteSpace(partyTypePairTitle));
            Contract.Requires(partyTypePairAlowedSource != null && partyTypePairAlowedSource.Id > 0);
            Contract.Requires(partyTypePairAlowedTarget != null && partyTypePairAlowedTarget.Id > 0);
            Contract.Ensures((Contract.Result<PartyRelationshipType>() != null && Contract.Result<PartyRelationshipType>().Id >= 0)
                && (Contract.Result<PartyTypePair>() != null && Contract.Result<PartyTypePair>().Id >= 0));

            PartyRelationshipType entity = new PartyRelationshipType()
            {
                Description = description,
                IndicatesHierarchy = indicatesHierarchy,
                MaxCardinality = maxCardinality,
                MinCardinality = minCardinality,
                Title = title
            };
            var partyTypeEntity = new PartyTypePair()
            {
                AlowedSource = partyTypePairAlowedSource,
                AlowedTarget = partyTypePairAlowedTarget,
                Description = partyTypePairDescription,
                PartyRelationshipType = entity,
                Title = partyTypePairTitle
            };

            using (IUnitOfWork uow = this.GetUnitOfWork())
            {
                IRepository<PartyRelationshipType> repo = uow.GetRepository<PartyRelationshipType>();
                IRepository<PartyTypePair> repoPTP = uow.GetRepository<PartyTypePair>();
                repo.Put(entity);
                repoPTP.Put(partyTypeEntity);
                uow.Commit();
            }
            return (entity);
        }
Esempio n. 3
0
        public PartyX Create(PartyType partyType, string name, string alias, string description, DateTime? startDate, DateTime? endDate, PartyStatusType statusType)
        {
            Contract.Requires(!string.IsNullOrWhiteSpace(name));
            Contract.Requires(partyType != null);
            Contract.Requires(statusType != null);
            Contract.Requires(partyType.StatusTypes.Contains(statusType));
            Contract.Ensures(Contract.Result<PartyX>() != null && Contract.Result<PartyX>().Id >= 0);
            if (startDate == null)
                startDate = DateTime.MinValue;
            if (endDate == null || endDate==DateTime.MinValue)
                endDate = DateTime.MaxValue;
            //Create a create status
            PartyStatus initialStatus = new PartyStatus();
            initialStatus.Timestamp = DateTime.UtcNow;
            initialStatus.Description = "Created";
            initialStatus.StatusType = statusType;

            PartyX entity = new PartyX()
            {
                PartyType = partyType,
                Name = name,
                Alias = alias,
                Description = description,
                StartDate = startDate.Value,
                EndDate = endDate.Value,
                CurrentStatus = initialStatus
            };
            initialStatus.Party = entity;
            entity.History = new List<PartyStatus>();
            entity.History.Add(initialStatus);
            using (IUnitOfWork uow = this.GetUnitOfWork())
            {
                IRepository<PartyX> repo = uow.GetRepository<PartyX>();
                repo.Put(entity); // must store the status objects too
                uow.Commit();
            }
            return (entity);
        }
Esempio n. 4
0
 private Dlm.Entities.Party.PartyTypePair addTestPartyTypePair(PartyType alowedSource, PartyType alowedTarget)
 {
     Dlm.Services.Party.PartyRelationshipTypeManager pmr = new Dlm.Services.Party.PartyRelationshipTypeManager();
     return pmr.AddPartyTypePair("TitleTest", alowedSource, alowedTarget, "rel Type test", null);
 }
Esempio n. 5
0
 private void removePartyType(PartyType partyType)
 {
     Dlm.Services.Party.PartyTypeManager ptm = new Dlm.Services.Party.PartyTypeManager();
     ptm.Delete(partyType);
 }
Esempio n. 6
0
 private Dlm.Entities.Party.PartyRelationshipType addTestPartyRelationshipType(PartyType alowedSource, PartyType alowedTarget)
 {
     Dlm.Services.Party.PartyRelationshipTypeManager pmr = new Dlm.Services.Party.PartyRelationshipTypeManager();
     return pmr.Create("test", " ", false, 3, 2, alowedSource, alowedTarget, "", "");
 }
Esempio n. 7
0
        private Dlm.Entities.Party.Party addTestParty(PartyType partyType, PartyStatusType st)
        {
            Dlm.Services.Party.PartyManager pm = new Dlm.Services.Party.PartyManager();

            var party = pm.Create(partyType, "partyTest", "", "party created for test", null, null, st);
            return party;
        }
Esempio n. 8
0
 private Dlm.Entities.Party.PartyStatusType addPartyStatusType(PartyType partyType)
 {
     Dlm.Services.Party.PartyTypeManager ptm = new Dlm.Services.Party.PartyTypeManager();
     return ptm.AddStatusType(partyType, "just created", "this is for test data", 0);
 }
Esempio n. 9
0
 public Party()
 {
     CustomAttributeValues = new List <PartyCustomAttributeValue>();
     PartyType             = new PartyType();
     History = new List <PartyStatus>();
 }
Esempio n. 10
0
File: Party.cs Progetto: BEXIS2/Core
 public Party()
 {
     CustomAttributeValues = new List<PartyCustomAttributeValue>();
     PartyType = new PartyType();
     History = new List<PartyStatus>();
 }