BExIS.Dlm.Services.Party.PartyRelationshipTypeManager.AddPartyTypePair C# (CSharp) 메소드

AddPartyTypePair() 공개 메소드

public AddPartyTypePair ( string title, PartyType alowedSource, PartyType alowedTarget, string description, PartyRelationshipType partyRelationshipType ) : PartyTypePair
title string
alowedSource BExIS.Dlm.Entities.Party.PartyType
alowedTarget BExIS.Dlm.Entities.Party.PartyType
description string
partyRelationshipType BExIS.Dlm.Entities.Party.PartyRelationshipType
리턴 BExIS.Dlm.Entities.Party.PartyTypePair
        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);
        }