public bool Disenroll(string user, long structure, long container, string roleType)
{
var userObj = Get(user);
var containerObj = _db.Container.Get(container);
var roleTypeObj = _db.RoleType.Get( structure, roleType);
var enroll = _db.DbContext.Enrolls.Find(user, container, roleType, structure);
if (enroll == null)
return false; //TODO throw exception
if (enroll.Inherited)
return false; //TODO throw exception
if (enroll.InheritedCount == 0)
{
_db.DbContext.Enrolls.Remove(enroll);
InvokeOnDisenrollUser(enroll, containerObj);
}else
enroll.Inherited = true;
InheritedDisenrollChilds(userObj, containerObj, roleTypeObj);
InheritedDisenrollParents(userObj, containerObj.Parent, roleTypeObj);
return _db.DbContext.SaveChanges() != 0;
}