public bool AddAssociatedDataType(Unit end1, IEnumerable<DataType> end2)
{
Contract.Requires(end1 != null && end1.Id >= 0);
Contract.Requires(Contract.ForAll(end2, (DataType e) => e != null));
Contract.Requires(Contract.ForAll(end2, (DataType e) => e.Id >= 0));
bool result = false;
using (IUnitOfWork uow = this.GetUnitOfWork())
{
IRepository<Unit> repo = uow.GetRepository<Unit>();
end1 = repo.Reload(end1);
repo.LoadIfNot(end1.AssociatedDataTypes);
foreach (var e2 in end2)
{
if (!end1.AssociatedDataTypes.Contains(e2))
{
end1.AssociatedDataTypes.Add(e2);
e2.ApplicableUnits.Add(end1);
}
}
uow.Commit();
result = true;
}
return (result);
}