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);
}