public void IsPerson() { var target = ModuleOwnershipRef.Person(10); Assert.IsTrue(target.IsAny); Assert.IsTrue(target.IsPerson); Assert.IsFalse(target.IsGroup); Assert.IsFalse(target.IsPersonInGroup); Assert.IsFalse(target.IsNone); Assert.AreEqual(10, target.PersonId); Assert.AreEqual(0, target.GroupId); }
public async Task <(int Count, string Message, Person?Entity)> SaveAsync(ClaimsPrincipal?principal, Person entity, bool isGroupAdministrator = false) { var ownerRef = ModuleOwnershipRef.Person(entity.Id); if (principal.MaySave(ownerRef, isGroupAdministrator)) { using var dbContext = Factory.CreateDbContext(); dbContext.People.Attach(entity); dbContext.Entry(entity).State = entity.Id.GetState(); var count = await dbContext.SaveChangesAsync(); return(count.SaveResult(entity)); } return(principal.SaveNotAuthorised <Person>()); }