Example #1
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);
        }
Example #2
0
 private void removePartyStatusType(PartyStatusType partyStatusType)
 {
     Dlm.Services.Party.PartyTypeManager ptm = new Dlm.Services.Party.PartyTypeManager();
     ptm.RemoveStatusType(partyStatusType);
 }
Example #3
0
        public PartyStatus AddPartyStatus(PartyX party, PartyStatusType partyStatusType, string description)
        {
            Contract.Requires(party != null);
            Contract.Requires(partyStatusType != null);
            Contract.Ensures(Contract.Result<PartyStatus>() != null && Contract.Result<PartyStatus>().Id >= 0);
            var entity = new PartyStatus()
            {
                Description = description,
                Party = party,
                StatusType = partyStatusType,
                Timestamp = DateTime.Now
            };
            using (IUnitOfWork uow = this.GetUnitOfWork())
            {
                IRepository<PartyStatus> repoStatus = uow.GetRepository<PartyStatus>();

                repoStatus.Put(entity);
                // The current status must get updated, too. dependes on the current status's update logic.
                uow.Commit();
            }
            return (entity);
        }
Example #4
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;
        }