BExIS.Dlm.Services.Party.PartyManager.Delete C# (CSharp) Method

Delete() public method

public Delete ( IEnumerable entities ) : bool
entities IEnumerable
return bool
        public bool Delete(IEnumerable<PartyX> entities)
        {
            Contract.Requires(entities != null);
            Contract.Requires(Contract.ForAll(entities, (PartyX e) => e != null));
            Contract.Requires(Contract.ForAll(entities, (PartyX e) => e.Id >= 0));
            using (IUnitOfWork uow = this.GetUnitOfWork())
            {
                IRepository<PartyX> repo = uow.GetRepository<PartyX>();
                IRepository<PartyStatus> repoCM = uow.GetRepository<PartyStatus>();
                foreach (var entity in entities)
                {
                    var latest = repo.Reload(entity);
                    // remove all associations between the entity and its history items
                    repoCM.Delete(latest.History);
                    entity.History.ToList().ForEach(a => a.Party = null);
                    entity.History.Clear();
                    //delete the unit
                    repo.Delete(latest);
                }
                // commit changes
                uow.Commit();
            }
            return (true);
        }

Same methods

PartyManager::Delete ( Party entity ) : bool

Usage Example

コード例 #1
0
ファイル: PartyController.cs プロジェクト: BEXIS2/Core
 public ActionResult Delete(Party party)
 {
     PartyManager partyManager = new PartyManager();
     //  party = partyManager.Repo.Reload(party);
     partyManager.Delete(party);
     return RedirectToAction("Index");
 }